unix:freebsd:installing_to_usb_thumbdrive
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | unix:freebsd:installing_to_usb_thumbdrive [2019/03/28 00:04] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Installing on USB Thumbdrive ====== | ||
| + | |||
| + | The main thing with using a USB thumbdrive is to decrease the number of writes. Compared to SSD and platter based block storage devices (disk drives, called " | ||
| + | |||
| + | As soon as possible after doing the initial install, begin decreasing writes by modifying the atime parameter on anything stored on the USB, then moving active partitions (/tmp, /var/log, /var/run, etc...) off of the USB, either into a Memory Device (aka md, RAMDisk), and SSD or, preferably, a " | ||
| + | |||
| + | ===== Quick and Dirty ===== | ||
| + | |||
| + | * Install your base system using UFS. I do a manual creation and simply use the entire space for /, then began tweaking | ||
| + | * When given the opportunity to create the partition, do manual partitioning and set the following options in the Configure section: | ||
| + | * SUJ off (turn off journaling, since this generates a lot of writes) | ||
| + | * TRIM on (let TRIM work to balance where the writes go, SSD only) | ||
| + | * SU on | ||
| + | * The most important thing to decrease writes is to set that //noatime// parameter. This greatly reduces writes (we'll handle the other constant writes later). | ||
| + | * Put /tmp in md and point /var/tmp to it. If you have plenty of memory, this is very simple and really, really fast. | ||
| + | * Build your disk set of spinners. In my setup, I had a ZFS Z-RAID on some 10k drives, and an SSD card for the ZFS cache (I needed speed since it was planned to be a iSCSI server). | ||
| + | * put the following onto separate partitions on the spinners: | ||
| + | * /var/log | ||
| + | * /var/run | ||
| + | * swap | ||
| + | |||
| + | ===== More Detail ===== | ||
| + | |||
| + | When I am done, my fstab looks like this. | ||
| + | |||
| + | < | ||
| + | # Device Mountpoint FStype Options Dump | ||
| + | / | ||
| + | md11 /tmp mfs | ||
| + | md / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | **Note** If you use //pkg// for your installation, | ||
| + | |||
| + | The above is a little different, since I already had an SSD in the system as the L2ARC for ZFS. FreeBSD does not require L2ARC have an entire device, so I was able to partition this out to give myself a block for swap. This particular card is actually two small devices which can be RAID' | ||
| + | |||
| + | I also created a small mfs for /tmp and /var/run. /tmp really needs 256M (128 will work) if you are using pkg to install. If you use ports, most of the action takes place in the /usr/ports and /usr/src directories, | ||
| + | |||
| + | One thing is to point /var/tmp to /tmp. That is as simple as making sure nothing is using /var/tmp (do an ls, some files are ok), then run the following: | ||
| + | <code bash> | ||
| + | rm -fRv /var/tmp | ||
| + | ln -s /tmp /var/tmp | ||
| + | </ | ||
| + | |||
| + | I set up /var/log on the zfs platter I created after the fact, so it doesn' | ||
| + | |||
| + | <code bash> | ||
| + | zfs create storage/ | ||
| + | mv /var/log/* / | ||
| + | zfs set checksum=off atime=off exec=off | ||
| + | service syslogd restart | ||
| + | mount | ||
| + | </ | ||
| + | |||
| + | If you are going to use the Ports collection, it will do a lot of work in /usr/ports, so we want to fix that also. **Note** I think it does all its work in the /usr/port/* directory, but I have not been able to verify that. | ||
| + | <code bash> | ||
| + | zfs create storage/ | ||
| + | mv / | ||
| + | zfs set checksum=off atime=off exec=off mountpoint=/ | ||
| + | </ | ||
| + | Now, you can see the results of your mounted directories | ||
| + | <code bash> | ||
| + | mount | ||
| + | </ | ||
| + | The output of the above command will show you the mounted file system | ||
| + | < | ||
| + | /dev/da4s1a on / (ufs, local, noatime, journaled soft-updates) | ||
| + | devfs on /dev (devfs, local, multilabel) | ||
| + | /dev/md0 on /tmp (ufs, local, noatime, nosuid, soft-updates) | ||
| + | /dev/md1 on /var/run (ufs, local, noatime, nosuid, soft-updates) | ||
| + | storage on /storage (zfs, local, nfsv4acls) | ||
| + | storage/ | ||
| + | </ | ||
| + | |||
| + | ===== Other Options ===== | ||
| + | |||
| + | **Note** I have found that booting from an image on some enterprise servers requires you to reconfigure the BIOS, telling it to boot off the new " | ||
| + | |||
| + | ==== Duplicate your boot device ==== | ||
| + | |||
| + | There are some really great options available when booting from USB that I ran into. Manual installs, installations with two copies of the boot image on the flash (http:// | ||
| + | |||
| + | The best one is, however, the ability to store an image very nicely and recreate the boot device if you ever need to. To do this. | ||
| + | - Remove USB from drive | ||
| + | - Plug into a second system | ||
| + | - Use the //dd// command to make a copy. | ||
| + | - Determine the USB drive name | ||
| + | - Determine an output file on a device which has sufficient space | ||
| + | - <code bash>dd if=/dev/ad0 of=/ | ||
| + | - You can now create a second device by simply using //dd// to copy from the file back to it. | ||
| + | - Determine the USB drive name (assume ad0 for this) | ||
| + | - dd if=/ | ||
| + | |||
| + | The //&& | ||
| + | |||
| + | ==== Manually tune file system ==== | ||
| + | |||
| + | If you forgot to set journaling off, trim on, etc..., you can do it now. | ||
| + | |||
| + | You can not modify a slice (partition) which is mounted rw, so reboot into single user mode. It will show you the volume mounted as read only. | ||
| + | |||
| + | Look at what is currently set on your volume | ||
| + | <code bash> | ||
| + | tunefs -p /dev/da0p3 | ||
| + | </ | ||
| + | Now, you can fix anything which is set incorrectly. We are going to disable | ||
| + | * -j soft updates journaling | ||
| + | * -J gjournal flag | ||
| + | * -n soft updates | ||
| + | and enable | ||
| + | * -t trim | ||
| + | <code bash> | ||
| + | tune2fs -j disable -J disable -n disable -t enable /dev/da0p3 | ||
| + | </ | ||
| + | |||
| + | If you had to add trim, there are likely a bunch of blocks which are not flagged. To fix this, issue: | ||
| + | <code bash> | ||
| + | fsck_ufs -Ey /dev/da0p3 | ||
| + | </ | ||
| + | |||
| + | ==== Set label on root file system ==== | ||
| + | <code bash> | ||
| + | tunefs -L root /dev/da0p3 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== References ===== | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
unix/freebsd/installing_to_usb_thumbdrive.txt · Last modified: 2019/03/28 00:04 by 127.0.0.1
