Tuesday, December 14, 2021

Creating a Window 10 Live USB Stick on an Ubuntu GNU/Linux Computer

As a hardcore user of GNU/Linux systems, I don't usually come across any requirement to use Windows operating system. However recently, I had to install Windows in somebody else's computer as a help. It took me a while to find out how to prepare a installation USB drive for the purpose. Here's the steps I followed, hoping that my future self may need to refer back one day.

1. Download Window 10 ISO file from the official Microsoft website.


2. Download and install WoeUSB-ng on the Ubuntu computer using the information in the following Github page: https://github.com/WoeUSB/WoeUSB-ng


3. Run the following command to make the USB device (/dev/sdb in my case) bootable with the downloaded Windows ISO file. If there are files in the Windows 10 ISO file that are bigger than 4GB, the following command will automatically revert to NTFS format. 


sudo woeusb --target-filesystem FAT --device ~/Downloads/Win10_21H2_EnglishInternational_x64.iso /dev/sdb 

References:

Thursday, March 25, 2021

Enabling Hibernation in Ubuntu 20.04 LTS using a Swap File

Enabling of the hibernation option on Ubuntu 20.04 LTS didn't work in the way I used to do. So, I had to explore further and do it slightly differently. This blog post records those things I did to get hibernation option working.

1. First of all, create a swap file using the following commands.

sudo fallocate -l 17G /swapfile

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile


Once done, add an entry to the end of /etc/fstab file to make use of this swap file as follows.

/swapfile none swap sw 0 0

2. Check the UUID of the partition where the swap file is located using the following command.

cat /etc/fstab

Take note of the UUID string, which we will need in a later step.

3. Check the offset to the swapfile with in the storage device using either of the following commands. Take note of that offset value.

sudo filefrag -v /swapfile | awk '{ if($1=="0:"){print substr($4, 1, length($4)-2)} }'

sudo swap-offset /swapfile

4. Now, open the /etc/default/grub file and add update the correct line as follows.

Original line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Updated line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=a27fc21e-3315-4497-99aa-1fe7fad64091 resume_offset=9807872"

Note that the UUID value and the resume offset value are found using the above steps 2 and 3.

Once this grub file is updated, run the following command to take the changes effect.

sudo update-grub

5. Test whether the hibernation option is working now, use either of the following commands. I personally prefer the second command as it provides some verbose output while the system is being hibernated and being resumed later.

sudo systemctl hibernate

sudo pm-hibernate

Cheers!


References:

  1. https://linuxize.com/post/create-a-linux-swap-file/
  2. https://askubuntu.com/questions/1240123/how-to-enable-hibernate-option-in-ubuntu-20-04
  3. https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file