[LINUX] I installed Ubuntu on a USB stick on a dual boot PC


This is Qiita's first post. I bought it at the university co-op ~~ It was shit late ~~ I am doing dual boot of Ubuntu + Windows using the co-op PC. I basically use it at home, but it's heavy and annoying to bring it to university. What if your PC is crushed by the rush hour? So, I installed it on a USB memory so that I could carry the Ubuntu environment with me.

Device used

--Buffalo USB memory: 2GB (small capacity, write iso) / dev / sdb --ELSONIC USB memory: 16GB (large capacity, Ubuntu installation destination) / dev / sdc

writing iso

I did it a year ago so I forgot how I did it. Was it Unetbootin?

USB memory partition

Boot from the smaller USB stick ( / dev / sdb). Select Try Ubuntu without Installing. Connect the larger USB stick ( `/ dev / sdc```) and mess with the partition with GParted. [Reference site](https://cloud-work.net/usb%E3%83%96%E3%83%BC%E3%83%88/usb_install/#USB-2 ), I found that if I secured an area at the beginning of the USB memory in fat32 format, it could be accessed from Windows, so I edited the partition in the same way ( / dev / sdc1```). After that, create an ext4 partition (`` / dev / sdc2```) where Ubuntu will be installed. I didn't create a swap area.

2020.5.3 Addendum: EFI partition (mount point is / boot / efi) is required to boot UEFI. It seems better to proceed without creating a partition for data sharing with Windows and make `` `/ dev / sdc1``` an EFI partition.


Double-click "Install Ubuntu 18.04" on your desktop. If you make a mistake, the SSD data will fly, so be careful (the theory that you should have removed the SSD in the first place). Note that parts such as `` `/ dev / sdc2``` will change depending on the environment, so please read as appropriate.

--"Installation type": Others` `` --Mount point ( / dev / sdc2): / --Device to install bootloader: / dev / sdc

IMG_20191224_090143_25per.jpg IMG_20191224_092058_25per_2.jpg

I changed the setting because the bottom of the screen was cut off due to the resolution and I could not select the menu of the device to install the boot loader.

$ xrandr --output eDP-1 --mode 1920x1440

Try to start

――Can you boot as usual by removing the larger USB memory (from SSD) → Can't boot (sweat) --A grub rescue screen appears --Start with the larger USB memory attached → GRUB has all the OSs registered, so this seems to be okay (I didn't do it after all)

Repair SSD bootloader

--It's bad not to boot without the larger USB stick --Repair by removing the larger USB memory. Reference site (web archive) is okay It was. Rest assured for the time being.

Repair the boot loader of the larger USB stick

This was done using another PC with Windows only installed. Set the EFI partition to / dev / sdc1 (change the partition for sharing later).

-Reference site (web archive).

Boot from the larger USB stick

IMG_20191224_131701_tr_2.jpg You can now select Ubuntu from the grub os selection screen.

However, after this, the login screen did not appear and I was in emergency mode. When I googled, `` `/ etc / fstab``` seems to be suspicious.

# cat /etc/fstab

It was set to read / dev / sda3 (SSD boot loader) at boot time. [](Although a directory like `/ boot / efi``` was created, the contents were empty.) → Make `/ dev / sdc1``` read.

Re-edit partition

Create a separate partition for sharing. The order of the numbers has changed.

-- / dev / sdc3: For sharing (fat32), mount on `/ windows``` --``` / dev / sdc1```: Bootloader (changed to), mounted on / boot / efi``` --``` / dev / sdc2```: ubuntu, mount on `` /` ``

Write the mount settings by specifying the corresponding UUID.


# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdc2 during installation
UUID=hoge  /               ext4    noatime,errors=remount-ro 0       1
# /boot/efi => /dev/Change to sdc1
UUID=fuga  /boot/efi       vfat    umask=0077      0       1
# /windows => /dev/Change to sdc3
UUID=piyo  /windows        vfat    noatime,users,rw,utf8,uid=1000,gid=1000,fmask=133,dmask=022 0       1

#do not use swap

tmpfs /tmp tmpfs defaults,noatime,size=512m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,size=512m 0 0
tmpfs /var/log tmpfs defaults,noatime,size=512m 0 0

UUID=foo /media/(username)/C auto nofail,noatime,users,rw,uid=1000,gid=1000,fmask=133,dmask=022 0 0
UUID=bar /media/(username)/D auto nofail,noatime,users,rw,uid=1000,gid=1000,fmask=133,dmask=022 0 0

I was able to start

When automatically mounting SSD etc., it may not be possible to start unless you write `nofail``` in the setting of `/ etc / fstab``` (when it cannot be mounted such as starting on another PC) It will be in emergency mode soon). It cannot be mounted with Windows BitLocker running (that's right).

Was the partition table msdos?

$ sudo parted -l
model:   (scsi)
disk/dev/sdc: 15.9GB
Sector size(logic/Physics): 512B/512B
Partition table: msdos
Disk flag: 

Number Start End Size Type File system flag
 3    1049kB  3461MB  3460MB  primary  fat32
 1    3671MB  4195MB  524MB   primary  fat32             boot, lba
 2    4195MB  15.8GB  11.6GB  primary  ext4
 4    15.8GB  15.9GB  105MB   primary  fat32

Screenshot from 2019-12-27 08-53-42.png

I can still start it. Is it a combination of UEFI-MBR?

Measures to extend the life of USB memory Memo

It is unknown how effective it is.

--Increase the value of vm.dirty_writeback_centisecs in /etc/sysctl.conf --Move mlocate from cron.daily to cron.weekly --Settings in / etc / fstab - tmpfs (/tmp, /var/tmp, /var/log) - noatime

Various settings (1, 2) (3) (4 )

  1. Solved the problem that the time is off by 9 hours on Ubuntu and Windows

$ timedatectl set-local-rtc true ```

  1. Change the directory name to English

$ LANG=C xdg-user-dirs-gtk-update ``` 3. Swap ctrl and caps


XKBOPTIONS="ctrl:swapcaps" ```

  1. Solved the problem that the touchpad does not respond on the laptop

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.notimeout i8042.nomux" ```

For Ubuntu 20.04

2020.5.3 Addendum: When I tried it in the same way, it failed as expected, so I repaired the boot loader. At the time of installation

The partition table of the following devices will be modified:
SCSI1 (0,0,0) (sda)

If you see something other than the device you are installing to (`` `/ dev / sdc```), it will likely fail. Screenshot from 2020-04-26 06-45-23.png


I tried to see if the fat32 partition could be read by Windows even if it was at the end (across ext4) instead of the first, and it was (and was possible). The site I referred to was quite old, so it's important to check the latest information. I want Windows 10 to stop consuming 2GB of memory just by booting (I hate this and don't want to use virtual environments).

Thank you for reading to the end.

Recommended Posts

I installed Ubuntu on a USB stick on a dual boot PC
I installed tensorRT on Ubuntu 18.04
I installed ROS on Ubuntu 18.04
Install Linux (CentOS) on your PC using a USB stick
I installed TensorFlow (GPU version) on Ubuntu
I installed Kivy on a Mac environment
Usual dual boot Ubuntu
I got a UnicodeDecodeError when pip install on ubuntu
I made a Python3 environment on Ubuntu with direnv.
I want a Spotify sleep timer on my PC
USB Wifi on Ubuntu 20.04LTS
I installed FreeCAD on Linux (Ubuntu) and created an icon
Connect a commercially available webcam to a PC with ubuntu 16.04 installed via USB and capture video with python
Share the physical volume of a dual boot PC between OSs.
I installed Taiga.IO on CentOS7 (I made a script while I was there)
Create a USB boot Ubuntu with a Python environment for data analysis
Remove ubuntu installed on Windows 10 machine
Building a Python environment on Ubuntu
[Linux] I installed CentOS on VirtualBox
I tried Cython on Ubuntu on VirtualBox
Using a serial console on Ubuntu 20.04
I couldn't input Japanese on Ubuntu 20.04
I installed Linux on my Mac
Create a permanent write area on Kali Linux with USB memory boot
[Super rudimentary] I installed GDAL on Anaconda
USB boot on Raspberry Pi 4 Model B
RTKLIB 2.4.3 CLI version GUI version installed on Ubuntu 18.04
I stumbled upon installing sentencepiece on ubuntu
I built a TensorFlow environment on windows10
I installed OpenCV-Python on my Raspberry Pi
Until you create an Ubuntu boot USB on your Macbook and install Ubuntu on your Thinkpad