[筆記] chroot 步驟
假設我有一個完整的linux系統在/dev/sdb1上,且掛載在/media/test
要執行chroot去修改/dev/sdb1上的系統,需要執行以下步驟:
如果需要網路連線:(非必要)
copy hosts file for networking...
掛載檔案系統:
P.S. 根據mount的manul:
Since Linux 2.4.0 it is possible to remount part of the file hierarchy
somewhere else. The call is
mount --bind olddir newdir
所以其實是把原系統/dev同時掛載到/dev/sdb1系統的/dev上,這樣才可以控制週邊硬體
再來就是chroot
掛載proc,sysfs,devpts
然後你目前的工作環境就出現在/dev/sdb1中的系統裡了
可以fix GRUB 或做一些系統修復...
要執行chroot去修改/dev/sdb1上的系統,需要執行以下步驟:
cd /media/test
如果需要網路連線:(非必要)
sudo cp /etc/resolv.conf /media/test/etc/
copy hosts file for networking...
sudo cp /etc/hosts /media/test/etc/
掛載檔案系統:
sudo mount --bind /dev /media/test/dev
P.S. 根據mount的manul:
Since Linux 2.4.0 it is possible to remount part of the file hierarchy
somewhere else. The call is
mount --bind olddir newdir
所以其實是把原系統/dev同時掛載到/dev/sdb1系統的/dev上,這樣才可以控制週邊硬體
再來就是chroot
sudo chroot /media/test
掛載proc,sysfs,devpts
mount -t proc none /media/test/proc
mount -t sysfs none /media/test/sys
mount -t devpts none /dev/pts
然後你目前的工作環境就出現在/dev/sdb1中的系統裡了
可以fix GRUB 或做一些系統修復...
留言