Anh Trinh JavaScript Developer

Using Lvm To Move Ubuntu To New Ssd

Moving old LVM Partition to the new SSD

After you have installed the SSD, in my case, it is located at /dev/nvme0n1, and let say your current Ubuntu is installed at /dev/sdOLD

# Make it a LVM Physical volume
sudo pvcreate /dev/nvme0n1

# Verify it
sudo lvmdiskscan

# My result:
#  /dev/nvme0n1          [     232.89 GiB] LVM physical volume#
#  /dev/ubuntu-vg/root   [      123.31 GiB]
#  .....
#  /dev/sdOLD   [      123.31 GiB] LVM physical volume#
# 

# Add the new LVM volume to existing ubuntu-vg LVM group
sudo vgextend ubuntu-vg /dev/nvme0n1

# Moving the old partion to the new 
sudo pvmove /dev/sdOLD

# Removing the old volume from ubunut-vg group 
sudo vgreduce ubuntu-vg /dev/sdOLD

# Remove the physical logical volume (if you wish)
sudo pvremove /dev/sdOLD

# Updating grub
sudo update-grub
sudo grub-install /dev/nvme0n1

Moving your home folder to new SSD

# create new logical volume on the remaining space
sudo lvcreate -l 100%FREE -n home ubuntu-vg

# make file system
sudo mkfs -t ext4 /dev/ubuntu-vg/home

# mount
sudo mount /dev/ubuntu-vg/home /mnt/home

# RSync the home folder
sudo rsync -aXS --info=progress2 /home/. /mnt/home/.

# Backup the current /home
cd /
sudo mv /home /home_backup

# Mount /home to the new location
sudo mkdir /home

# Change fstab
sudo vim /etc/fstab

# Add following line:
UUID=<your_partition_uui>   /home   ext4    nodev,nosuid  0 2

# ( To get the UUID you can use: $ sudo blkid )

# Logout and login again to check if it works
# If everything is find, delete the backup folder
sudo rm -rf /home_backup

# You might shrink your root partition
sudo lvresize -L 20G --resizefs /dev/ubuntu-vg/root

# To extend /home to take up all the free space
sudo lvresize -l +100%FREE --resizefs /dev/ubuntu-vg/home

References

  • Good introduction about LVM: https://www.digitalocean.com/community/tutorials/how-to-use-lvm-to-manage-storage-devices-on-ubuntu-16-04

  • The original idea is taken from the answer in this thread: https://askubuntu.com/questions/161279/how-do-i-move-my-lvm-250-gb-root-partition-to-a-new-120gb-hard-disk

Download Coursera Whole Notebook

Context: I am already using coursera-dl to download the videos and it works great, but I missed an analogous tool for the assignments.

GREAT NEWS!

I have just found a way to download all the assignment files from the coursera-notebook hub.

This saved me hours of painful single file downloading:

(adapted from here )

Go to the home of the coursera-notebook hub

Create a new python notebook

Execute !tar cvfz allfiles.tar.gz * in a cell

Download the archive !

Enjoy!

If the resulting archive is too big and you can’t download it

Open the python notebook where you executed last command and execute the following in a cell:

!split -b 200m allfiles.tar.gz allfiles.tar.gz.part.

This will split the archive into 200Mb blocks that you can download without a problem (if there is still a problem reduce the size by changing 200m to a lower value)

Then when you have downloaded all the split files reunite them on your system using the following command line (in a linux environment, or use cmder if you are on Windows):

cat allfiles.tar.gz.part.* > allfiles.tar.gz

PS: This is in fact valid in any Jupyter-notebook hub

Source: https://www.reddit.com/r/learnmachinelearning/comments/7er5ps/coursera_downloading_all_the_assignments_jupyter/?st=jfgfl0xh&sh=70d43f00

Install Cuda 9.1 Ubuntu 16.04 Notes

  • Use .deb (network) method

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=debnetwork

  • Download driver at www.nvidia.com/drivers, not not use PPA sudo add-apt-repository ppa:graphics-drivers because it’s not maintained by NVIDIA

Ref

Neuron Network Learning

Residual Networks - v2

In the Residual Networks programming excersise, there is one explaination about how ResNet works:

We also saw in lecture that having ResNet blocks with the shortcut also makes it very easy for one of the blocks to learn an identity function. This means that you can stack on additional ResNet blocks with little risk of harming training set performance. (There is also some evidence that the ease of learning an identity function–even more than skip connections helping with vanishing gradients–accounts for ResNets’ remarkable performance.)

Q: Why is that? What is “learning an identity function”? What is it used for in the learning process?

My Blog is now hosted in Github using Jekyll

Yay! And the syntax.css for syntax highlighting is generated with the command:

bundle exec rougify style base16.solarized.dark > syntax.css