NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Can I install NetBSD on the same usb installation disk?



## Writing the installation image onto an 8GB USB stick
##
~sysbuild/release/images # dd if=NetBSD-8.99.7-amd64-install.img ibs=64k | \
progress -l $(ls -l NetBSD-8.99.7-amd64-install.img | awk '{print $5}'
) dd of=/dev/rsd0d obs=64k
 99% |*****************************************  |  1447 MiB    7.95
MiB/s    00:00 ETA23200+0 records in
2969600+0 records out
1520435200 bytes transferred in 182.347 secs (8338142 bytes/sec)
2969600+0 records in
23200+0 records out
1520435200 bytes transferred in 182.345 secs (8338233 bytes/sec)
100% |****************************************|  1450 MiB    7.95
MiB/s    00:00 ETA

## Checking the disklabel and verifying the a slice is as small as expected....
##
~sysbuild/release/images # disklabel sd0
# /dev/rsd0:
type: ESDI
disk: image
label:
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 1450
total sectors: 2969600
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0

8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:   2967552      2048     4.2BSD   1024  8192    16  # (Cyl.      1 -   1449)
 c:   2967552      2048     unused      0     0        # (Cyl.      1 -   1449)
 d:   2969600         0     unused      0     0        # (Cyl.      0 -   1449)
~sysbuild/release/images # mount /dev/sd0a /mnt/a
~sysbuild/release/images # df -k /mnt/a
Filesystem    1K-blocks       Used      Avail %Cap Mounted on
/dev/sd0a       1459950     690844     696110  49% /mnt/a

~sysbuild/release/images # umount /mnt/a

## Using fdisk to extend the NetBSD primamry partition to the end of
the disk - notice the '$' on the 'size:' row
##

~sysbuild/release/images # fdisk -u sd0
Disk: /dev/rsd0
NetBSD disklabel disk geometry:
cylinders: 7680, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 15728640, bytes/sector: 512

BIOS disk geometry:
cylinders: 980, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 15728640

Partitions aligned to 2048 sector boundaries, offset 2048

Do you want to change our idea of what BIOS thinks? [n]

Partition table:
0: NetBSD (sysid 169)
    start 2048, size 2967552 (1449 MB, Cyls 0-184/216/32), Active
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
First active partition: 0
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none] 0
The data for partition 0 is:
NetBSD (sysid 169)
    start 2048, size 2967552 (1449 MB, Cyls 0-184/216/32), Active
sysid: [0..255 default: 169]
start: [0..979cyl default: 2048, 0cyl, 1MB]
size: [0..979cyl default: 2967552, 185cyl, 1449MB] $
bootmenu: [] (space to clear)

Partition table:
0: NetBSD (sysid 169)
    start 2048, size 15726592 (7679 MB, Cyls 0-979/15/60), Active
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
First active partition: 0
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none]

We haven't written the MBR back to disk yet.  This is your last chance.
Partition table:
0: NetBSD (sysid 169)
    start 2048, size 15726592 (7679 MB, Cyls 0-979/15/60), Active
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
Bootselector disabled.
First active partition: 0
Drive serial number: 0 (0x00000000)
Should we write new partition table? [n] y
##
## Our NetBSD partition went from 1449 to 7679 MB - above
##
## But of course the a slice is the same
##
~sysbuild/release/images # mount /dev/sd0a /mnt/a
~sysbuild/release/images # df -k /mnt/a
Filesystem    1K-blocks       Used      Avail %Cap Mounted on
/dev/sd0a       1459950     690844     696110  49% /mnt/a
~sysbuild/release/images # umount /mnt/a


## Extending the A slice
##
~sysbuild/release/images # disklabel -i sd0
Enter '?' for help
partition>A                     <------- that makes the NetBSD
partition cover the whole disk
Adjust disklabel sector from 2969600 to 15728640 [n]? y
partition>P                     <------- No change here still
8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:   2967552      2048     4.2BSD   1024  8192    16  # (Cyl.      1 -   1449)
 c:  15726592      2048     unused      0     0        # (Cyl.      1 -   7679)
 d:   2969600         0     unused      0     0        # (Cyl.      0 -   1449)
partition>a                     <----- Work on 'a'
Filesystem type [4.2BSD]:
Start offset ('x' to start after partition 'x') [1c, 2048s, 1M]:
Partition size ('$' for all remaining) [1449c, 2967552s, 1449M]: $
<---- extend 'a' to the max
 a:  15726592      2048     4.2BSD   1024  8192    16  # (Cyl.      1 -   7679)
partition>P                    <------- see below the augmented sizes
8 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 a:  15726592      2048     4.2BSD   1024  8192    16  # (Cyl.      1 -   7679)
 c:  15726592      2048     unused      0     0        # (Cyl.      1 -   7679)
 d:   2969600         0     unused      0     0        # (Cyl.      0 -   1449)
partition>W                <--------- write it down
Label disk [n]?y
Label written
partition>Q                <--------- get out

~sysbuild/release/images # fsck -fy /dev/rsd0a     <----- just in case
** /dev/rsd0a
** File system is already clean
** Last Mounted on /mnt/a
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
11270 files, 345422 used, 384553 free (1 frags, 48069 blocks, 0.0%
fragmentation)
~sysbuild/release/images # resize_ffs -y /dev/rsd0a    <----- really extend 'a'
~sysbuild/release/images # fsck -fy /dev/rsd0a         <----- that is needed
** /dev/rsd0a
** File system is already clean
** Last Mounted on /mnt/a
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
11270 files, 345422 used, 3523721 free (1 frags, 440465 blocks, 0.0%
fragmentation)
~sysbuild/release/images # mount /dev/sd0a /mnt/a       #### test the
new partition size
~sysbuild/release/images df -k /mnt/a
Filesystem    1K-blocks       Used      Avail %Cap Mounted on
/dev/sd0a       7738286     690844    6660528   9% /mnt/a        <----
looks good

Boot from this stick was also tested OK.

Obviously you can use the same technique to extend your 'a' slice and
extend and|or relocate your 'b'
swap slice on a live stick/disk. Also if you wanted, instead of
increasing the NetBSD primary
partition with fdisk at the beginning, you could create an MS-DOS
partition, format it FAT32 and use
it for other stuff.

This was lifted some times ago from the NetBSD Raspberry PI wiki.

Chavdar Ivanov


On 24 November 2017 at 15:14, Chavdar Ivanov <ci4ic4%gmail.com@localhost> wrote:
> Later, when I get back home.
>
>
> On Fri, 24 Nov 2017 at 15:09, Ottavio Caruso <ottavio2006-degen%yahoo.com@localhost>
> wrote:
>>
>>  On Fri 24 Nov 2017 at 07:47:49 -0700, Andy Ruhl wrote:
>> >> This is probably off topic, but I'll try anyway. I want to create a
>> >> USB install "disk", and then use another blank USB disk to install
>> >> onto.
>> >>
>> >> Does this work? I haven't tried yet. This would be nice to test things
>> >> out so I don't disrupt the internal disks.
>>
>> This is what I did when I installed NetBSD back in 2013. I did a fresh
>> installation onto a second usb stick and I tested it for a month or
>> so.
>> Painfully slow! Then I created a second partition on my main hard
>> drive and copied the files onto it.
>>
>> But.. going back to topic:
>>
>> On 24 November 2017 at 12:52, Chavdar Ivanov <ci4ic4%gmail.com@localhost> wrote:
>>
>> >
>> > Boot the stick single user, use fdisk to adjust the first partition to
>> > the
>> > end, use disklabel to extend the label to the en of the disk (A), then
>> > readjust the existing partitions (I move the b-partition to the end,
>> > adjusting a from the almost start to some space before the end for swap,
>> > then after writing the label use 'fsck -fy /dev/rsd0a' or wherever it
>> > is,
>> > then 'resize_ffs -y /dev/rsd0a', then again ; fsck -fy /dev/rsd0a'.
>>
>> Chavdar,
>>
>> if you don't mind, could you give me a breakdown of these commands? I
>> haven't used NetBSD fdisk in a while.
>>
>> --
>> Ottavio Caruso
>
> --
> ----



-- 
----


Home | Main Index | Thread Index | Old Index