把linux裝在U盤裏步驟詳解

雖然網上也有很多教程,但是我follow了很多還是沒有成功,最後在同學的幫助下終於成功了。

首先說明一下基本情況:我是將arch linux裝在一個16G的金士頓U盤裏,利用了另外一個4G的U盤製作了一個LIVE CD,注意,做LIVE CD的U盤在啓動linux之後是不能執行fdisk操作的,因此如果U盤A作爲LIVE CD,則系統只能裝在U盤B上或者其他硬盤上。

我是在windows下製作的LIVE CD,方法很多,這篇博客的內容很詳細,很好操作。

==================注:以下內容轉自(http://www.2cto.com/os/201207/143614.html)=======================================================

         準備工作:
 
        |  Unetbootin http://dl.dbank.com/c0j5a8kuom:Linux系統寫入U盤工具。
 
        |  BOOTICE http://dl.dbank.com/c0p0eaid5m:引導設置工具。
 
        |  你自己的Linux系統ISO鏡像。
 
        |  把U盤格式化成FAT32格式,對着U盤點右鍵--格式化即可,不需要什麼工具。
 
         第一步,使用unetbootin向U盤寫入Linux系統ISO鏡像。
 
        雙擊啓動Unetbootin,看到如下界面。
 
 
        選好後點確定。出現如下界面,大約30秒就能完成。
 
 
        完成以上步驟,就把Linux系統寫入U盤了。
 
        爲什麼要用Unetbootin寫入呢?UltraISO不行嗎?原因是僅僅把系統寫入U盤是無法啓動的,還需要用syslinux來引導,syslinux實際上是一個極小的Linux系統,只起引導作用。而Unetbootin恰恰自帶了syslinux,從上圖也可以看到,這樣就免去了手動安裝的繁瑣,UltraISO不具備此功能。
 
        第二步,使用BOOTICE設置U盤引導。
 
        啓動BOOTICE。選擇U盤,千萬別選硬盤啊。。。。然後點“主引導記錄”。
 
 
        在彈出的界面配置主引導爲UltraISOUSB-ZIP+。
 
 
        設置完成後關掉這個界面,回到主界面點“分區引導記錄”。  www.2cto.com  
 
 
        看一下分區引導記錄是不是syslinux,不是的話配置成syslinux,一般這步都沒問題。爲了保險起見還是看看比較好。。。。
 
 
        再次回到主界面,點擊“分區管理”。
 
 
        看看U盤是否設置成了活動分區,有A標記的就是活動分區,如果沒有的話,點“激活”即可。如果沒有設置成活動分區,電腦從U盤啓動的時候會無限彈出“Start from USB……”
 
 
        到此爲止,U盤就可以成功的啓動了。
 
        插上U盤,把電腦設置成從USB啓動即可。
=================================================================================================================================
插上製作好的LIVE CD,重啓電腦,在開機載入操作系統之前按下F12選擇從U盤引導。
然後接下來的可以follow arch wiki上的內容,其實裝在U盤裏面和裝在電腦硬盤裏面之前的步驟基本沒有區別。
但是arch linux有點蛋疼的地方,如果用LIVE CD做引導的話,會出現一個等待30秒的步驟,但最後失敗,提示/dev/disk/by-label/ARCH_201306 not found!  其中ARCH_201306視版本的不同而不同,201306表示2013年6月發行的版本。
解決方法是做一個軟鏈接,將LIVE CD所在的盤(如果是光盤或者iso引導,則是相應的loop區)鏈接到/dev/disk/by-label/ARCH_201306,命令如下:
ln -s /dev/sdd /dev/disk/by-label/ARCH_201306
其中/dev/sdd是LIVE CD所在的盤

=================注:以下內容部分轉自(https://wiki.archlinux.org/index.php/Installation_Guide)=====================================

Installation

Keyboard layout(綁定鍵盤,但是中國的鍵盤和美國標準鍵盤一致,所以可以跳過)

For many countries and keyboard types appropriate keymaps are available already, and a command like loadkeys uk might do what you want. More available keymap files can be found in /usr/share/kbd/keymaps/ (you can omit the keymap path and file extension when using loadkeys).

Partition disks(爲需要安裝linux的盤分區)

用fdisk命令,具體可以man fdisk或者fdisk --help

Format the partitions(格式化分區)

用命令mkfs.ext4之類的,如果需要格式化爲fat格式,則需要先安裝dosfstools

Mount the partitions(掛載分區)

注意,掛載的是要安裝linux的分區

We now must mount the root partition on /mnt. You should also create directories for and mount any other partitions (/mnt/boot/mnt/home, ...) and mount your swap partition if you want them to be detected by genfstab.

Connect to the internet(設置聯網)

A DHCP service is already enabled for all available devices. If you need to setup a static IP or use management tools such as Netctl, you should stop this service first: systemctl stop dhcpcd.service. For more information read configuring network.

Wireless

Run wifi-menu to set up your wireless network. For details, see Wireless Setup and Netctl.

Install the base system

Before installing, you may want to edit /etc/pacman.d/mirrorlist such that your preferred mirror is first. This copy of the mirrorlist will be installed on your new system by pacstrap as well, so it's worth getting it right.

Using the pacstrap script we install the base system.

# pacstrap /mnt base

Other packages can be installed by appending their names to the above command (space seperated), including the bootloader if you want.

Configure the system

  • Generate an fstab with the following command (if you prefer to use UUIDs or labels, add the -U or -L option, respectively):
# genfstab -p /mnt >> /mnt/etc/fstab
  • chroot into our newly installed system:
# arch-chroot /mnt
  • Write your hostname to /etc/hostname.
  • Symlink /etc/localtime to /usr/share/zoneinfo/Zone/SubZone. Replace Zone and Subzone to your liking. For example:
# ln -s /usr/share/zoneinfo/Europe/Athens /etc/localtime
  • Uncomment the selected locale in /etc/locale.gen and generate it with locale-gen.
  • Set locale preferences in /etc/locale.conf.
  • Add console keymap and font preferences in /etc/vconsole.conf
  • Configure /etc/mkinitcpio.conf as needed (see mkinitcpio) and create an initial RAM disk with:
# mkinitcpio -p linux

Install and configure a bootloader

You can choose GRUB or Syslinux.

GRUB

  • For BIOS:
# pacman -S grub-bios
  • For EFI (in rare cases you will need grub-efi-i386 instead):
# pacman -S grub-efi-x86_64

See GRUB installation and Configuration

Syslinux

# pacman -S syslinux

裝在電腦硬盤上的話,以上步驟就已經搞定了,卸載重啓就OK。但是裝在U盤上面還不行,重啓開機無法引導系統啓動。
需要安裝grub,注意,雖然前面安裝了grub但是對於安裝在U盤裏面,還需要再進行下列操作。注意:這些操作要在chroot的環境中進行,即在新安裝的linux下執行。
# pacman -S grub-bios os-prober

# grub-install /dev/sdc --boot-directory=/boot

# grub-mkconfig > /boot/grub/grub.cfg

不出意外的話,U盤就能引導U盤裏面的系統啓動了。


Unmount and reboot

If you are still in the chroot environment type exit or press Ctrl+D in order to exit. Earlier we mounted the partitions under /mnt. In this step we will unmount them:

# umount /mnt/{boot,home,}

Now reboot and then login into the new system with the root account.

==================================================================================================================================
接下來的一系列操作,安裝軟件等視各自需求,可以參考我的下一篇博客。(http://blog.csdn.net/piasy/article/details/9071867)


發佈了19 篇原創文章 · 獲贊 3 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章