Ubuntu 1504 Vivid Install To F2FS Filesystem

From richud.com
Revision as of 12:04, 11 February 2017 by Chud (talk | contribs) (Update 11 Feb 2017)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This should let you install Ubuntu 15.04 Vivid Vervet on the F2FS filesystem without a reboot.

You have to do it this way as

1) GRUB in Ubuntu 15.04 doesnt support F2FS and

2) Ubuntu installer cannot install to F2FS.


You should have, in no particular order.

1) A temp slave disk to install Ubuntu to initially. (/dev/sdb in this example)

2) A target drive (/dev/sda in this example)

3) A USB boot stick/disk with Ubuntu 15.04 written to it to boot from. (/dev/sdc in this example)

If sdc is USB stick,

dd if=ubuntu_xxxx.iso of=/dev/sdc bs=1M

Create Slave Image

Boot from USB and select 'Try Ubuntu' mode

Run the GUI Installer (Ubiquity)

Manually partition the slave disk with 250Mb ext2 partition mounted as '/boot' and the rest ext4 mounted '/', with the bootloader on /dev/sdb.

Once installed, 'continue trying ubuntu'.

Partition target drive

Install f2fs-tools

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install f2fs-tools

Start GParted, ignore error 'The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512' if you get it.

Create new partition table 'msdos'

Create two partitions, first 250Mb of disk ext2 (labelled in my example 'Boot_ext2'), second rest of disk f2fs (Labelled in my example 'Root_f2fs').

Set 'flags' on the ext2 partition to 'boot'.

Ignore red exclam on the newly created f2fs.

You should now have something like this, (I actually partitioned my slave disk first in gparted so labelled it Boot and Root, the default labels from doing direct in installer will be something else)

ubuntu@ubuntu:~$ sudo blkid
/dev/sdb1: LABEL="Boot" UUID="9fdca914-f565-4118-9417-c3a93fb111b0" TYPE="ext2" PARTUUID="c0b4ef0c-01"
/dev/sdb2: LABEL="Root" UUID="b4dd9484-8f44-4d5e-9b69-2a9b1b3c5f08" TYPE="ext4" PARTUUID="c0b4ef0c-02"
/dev/loop0: TYPE="squashfs"
/dev/sdc1: UUID="2015-04-22-12-30-17-00" LABEL="Ubuntu 15.04 amd64" TYPE="iso9660" PTUUID="1cae5859" PTTYPE="dos" PARTUUID="1cae5859-01"
/dev/sdc2: SEC_TYPE="msdos" UUID="2474-67AF" TYPE="vfat" PARTUUID="1cae5859-02"
/dev/sda1: LABEL="Boot_ext2" UUID="9033d4ad-37a6-4af4-95e0-5871033e7495" TYPE="ext2" PARTUUID="40d2e08d-01"
/dev/sda2: LABEL="Root_f2fs" UUID="80422ab9-add2-454c-9930-7ee53288705a" TYPE="f2fs" PARTUUID="40d2e08d-02"

Mount all partitions

Go into 'Disks' and click on all four partitions to mount them (Boot,Root,Boot_ext2,Boot_f2fs) (You can do it in Nautilus [Files] too but you may well get 'No Object for DBUS interface' error and no be able to mount some.)

You should now have them mounted like this

/dev/sda2 on /media/ubuntu/Root_f2fs type f2fs (rw,nosuid,nodev,relatime,background_gc=on,user_xattr,acl,active_logs=6,uhelper=udisks2)
/dev/sdb2 on /media/ubuntu/Root type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)
/dev/sdb1 on /media/ubuntu/Boot type ext2 (rw,nosuid,nodev,relatime,uhelper=udisks2)
/dev/sda1 on /media/ubuntu/Boot_ext2 type ext2 (rw,nosuid,nodev,relatime,uhelper=udisks2)

Copy data from slave to target

Now you need to copy everything from slave to target, be very careful getting them the right way round! This only takes about 4 minutes.

sudo rsync -avWHAX /media/ubuntu/Boot/ /media/ubuntu/Boot_ext2/
sudo rsync -avWHAX /media/ubuntu/Root/ /media/ubuntu/Root_f2fs/

Mount bind to target and chroot

Now mount bind the live system into the target.

  • Be careful to pick the right mounted target folders
  • Be careful to pick the correct target drive /dev/sdX the grub bootloader is going on, in this case /dev/sda

sudo mount -o bind /dev /media/ubuntu/Root_f2fs/dev
sudo mount -o bind /sys /media/ubuntu/Root_f2fs/sys
sudo mount -o bind /proc /media/ubuntu/Root_f2fs/proc
sudo mount -o bind /media/ubuntu/Boot_ext2 /media/ubuntu/Root_f2fs/boot
sudo chroot /media/ubuntu/Root_f2fs

Fixup fstab

Now you need to edit the target fstab

  • Replace both UUID's of the slave with the UUID's from the target
  • Replace 'ext4' with 'f2fs' on the root (/).
  • Replace errors=remount-ro with defaults, (be careful the f2fs options are different from other filesystems)

Original ending bit

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdc2 during installation
UUID=b4dd9484-8f44-4d5e-9b69-2a9b1b3c5f08 /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sdc1 during installation
UUID=9fdca914-f565-4118-9417-c3a93fb111b0 /boot           ext2    defaults        0       2

Replacement bit

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdc2 during installation
UUID=80422ab9-add2-454c-9930-7ee53288705a /               f2fs    defaults 0       1
# /boot was on /dev/sdc1 during installation
UUID=9033d4ad-37a6-4af4-95e0-5871033e7495 /boot           ext2    defaults        0       2

Fixup initramfs and grub

This adds f2fs modules to initramfs so when system boots it can see the f2fs root.

It then installs grub to the target drive.

nano /etc/fstab
echo "f2fs" >>  /etc/initramfs-tools/modules
update-initramfs -u
grub-install /dev/sda

This should produce the below.

root@ubuntu:/# echo "f2fs" >>  /etc/initramfs-tools/modules
root@ubuntu:/# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.19.0-15-generic
root@ubuntu:/# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
root@ubuntu:/# update-grub
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-3.19.0-15-generic
Found initrd image: /boot/initrd.img-3.19.0-15-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
grub-probe: error: cannot find a GRUB drive for /dev/sdc1.  Check your device.map.
Found Ubuntu 15.04 (15.04) on /dev/sdb2

Ignore error about sdc as that is the USB stick and it will also make a superfluous entry about the slave drive (will go on any subsequent grub kernel update)

Fixups for migrating machine

  • This only applies if you are moving the drive to another machine afterwards, or making multiple machines

Fixup Hostname

Replace the slave machine hostname with target in /etc/hosts (e.g. TARGETX) and also just the hostname in /etc/hostname

Fixup network

Remove everything from /etc/udev/rules.d/70-persistent-net.rules (otherwise network devices will not be how you expect (eth0 will be eth1 etc.)

And finally

Type Exit twice , Power off, remove USB stick and slave drive and it should boot into your new F2FS Ubuntu!


You probably just made an typo somewhere! There isn't much that can go wrong.

If you wonder why you are getting a ten second grub boot countdown it is because grub detected the O/S on slave drive when it generated the config. (This is because when grub only sees one OS it stops the menu coming up even when the default TIMEOUT is set to 10.) Once you have booted into the new system, just run 'sudo update-grub' to redo the menu if you wish to remedy.

Update 7 Sept 2015


I created the f2fs disk for my laptop on another machine and the laptop doesn't have f2fs tools installed. I installed fs2fs-tools to format a new ssd in the laptop (just replaced optical drive with a hdd holder) I have just spent several hours with it - it spontaneously reboots after booting to just before lightdm. Turns out f2fs-tools is causing it to reset, no idea why as of yet. remove --purge solves problem, adding it back causes problem. (you can get around issue by booting in rescue mode, running failsafe X, then going to tty2 and cntrl-c'ing X, then it boots into lightdm ok, wierd)

Update 11 Feb 2017

Ubuntu 16.04 f2fs-tools works fine now

Ubuntu 16.04.1 LTS after updating kernel 4.4 to 4.8 with

sudo apt-get install --install-recommends xserver-xorg-hwe-16.04

This bricked machine at initramfs not being able to find a root volume 'F2FS: Cannot load CRC32 driver'

You need to add one or two crc32 modules to load with initramfs, crc32_pclmul and crc32_generic (I think with a newish Intel CPU crc32_pclmul will suffice as only module after booting that appears to be in use, the crc32_generic is just a fallback...I think.)

# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
# Syntax:  module_name [args ...]
# You must run update-initramfs(8) to effect this change.
# Examples:
# raid1
# sd_mod

Thus append /etc/initramfs-tools/modules as above, rebuild with 'sudo update-initramfs -u' , reboot.


blog comments powered by Disqus