Change to single partition post install
You can change OpenBSD to run using a single partition after doing a default installation. You might rightly ask why on earth you would want to do this, after all the FAQ “encourages users to split their disk into a number of partitions”. Well it’s great if you have a large disk and in a secure implementation but what if you just want to run on a single partition to make better use of the disk or virtual disk space.
Requirements and disclaimer
Just because it can be done doesn't mean it should be done.
- Don’t do this if you’re at all interested in security and reliability!
- You need to be reasonably adept at using OpenBSD already, not new user friendly.
- You will need a second disk or a virtual disk to accomplish this.
- Definitely practise on a virtual machine BEFORE attempting this for real.
- Don’t blame me if you lose absolutely everything, make sure you have a backup.
- Remember that your data will be on the second disk if something does go wrong.
References
http://www.openbsd.org/faq/faq4.html#Partitioninghttp://www.openbsd.org/faq/faq14.html
Basic Steps
- Determine current disk and layout (df -h, note whether wd0 or sd0?)
- Shutdown
halt -p
- Attach second disk
- Power on
- Determine new disk name
sysctl hw.disknames
is it wd1 or sd0 etc? - Write MBR to new disk
fdisk -iy wd1
- Create partition on new disk
disklabel -E wd1, a a, w, q
- Create file system on new disk
newfs wd1a
- Mount second disk
mount /dev/wd1a /mnt
- What data to copy second disk (df -h to get a list of what to copy)
- Make directories of each top level mount point of source disk, /mnt/home, /mnt/usr, /mnt/var etc
- Copy all the data to the second disk:
cd /home && tar cf – . | (cd /mnt/home && tar xpf – )
cd /usr && tar cf – . | (cd /mnt/usr && tar xpf – )
cd /var && tar cf – . | (cd /mnt/var && tar xpf – )
- Don’t worry about socket errors
- Backup then edit fstab, add wxallowed to root mount point and remove all mounts after c
- Reboot using /bsd.rd at the loading screen and select (S)hell when prompted
- Make devices
cd /dev; sh MAKEDEV wd0 wd1
- Resize main disk
disklabel -E wd0
, p, make note of size of b partition - Remove partitions b and above, grow a with m and recreate swap
- Grow the a partition
growfs wd0a
thenfsck /dev/wd0a
mount /dev/wd1a /mnt and /dev/wd0a /mnt2
- Map keyboard layout (/mnt2/sbin/wsconsctl keyboard.encoding=uk)
- Restore data using tar
cd /mnt && tar cf – . | (cd /mnt2 && tar xpf – )
- Shutdown and remove second disk
halt -p
- Power on