在Ubuntu中當我們打開主檔案夾目錄的時候,系統便會自動的列出電腦裡的分區資訊。其中便有windows中的分區資訊,直接單擊它們便可以将它們挂載并顯示出來。而這種方式打開的分區一般被挂載在/meida下。除了這種方式挂載之外,我們也可以自己挂載分區。挂載分區的方法很簡單,通過mount可以完成:
mount /dev/sda* ./filename
/dev/sda*為你想挂載的分區的位址,而filename則是你要挂載到系統的相應位置的位址。解除安裝比較簡單,如下:
umount /dev/sda*
重點在于我們想把分區挂載在哪裡?我們要挂載那個分區?
一、分區資訊檢視
在Linux系統啟動的過程中會預設挂載Linux格式的分區,而Windows分區則需要我們來親自挂載。我們可以通過一下兩個指令來獲得Windows分區的資訊:fdisk,blkid。
我們能夠獲得分區的詳細資訊,通過該指令:
sudo fdisk -l
它會列出系統中分區的詳細資訊,但無法知道其盤符。通過該指令來擷取盤符資訊:
sudo blkid
通過相應的盤符與對應的分區資訊,我們可以确認我們所要挂載的分區。
二、挂載分區
分區的挂載通過mount指令來完成,可以使用umout來解除安裝分區。
三、示例:
1.檢視分區詳細資訊
[email protected]:~$ sudo fdisk -l
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x61c9f94b
Device Boot Start End Blocks Id System
/dev/sda1 * 63 102414374 51207156 7 HPFS/NTFS/exFAT
Partition 1 does not start on physical sector boundary.
/dev/sda2 102414436 625141759 261363662 f W95 Ext'd (LBA)
Partition 2 does not start on physical sector boundary.
/dev/sda5 102414438 256429529 77007546 7 HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6 256429593 410444684 77007546 7 HPFS/NTFS/exFAT
Partition 6 does not start on physical sector boundary.
/dev/sda7 410444748 510066368 49810810+ 7 HPFS/NTFS/exFAT
Partition 7 does not start on physical sector boundary.
/dev/sda8 510066688 514066431 1999872 83 Linux
/dev/sda9 514068480 621234175 53582848 83 Linux
/dev/sda10 621236224 625141759 1952768 82 Linux swap / Solaris
如上可以看到Linux檔案系統下的分區有/dev/sda8,/dev/sda9,/dev/sda10.這三個分區。而其餘的則是Windows下的分區,但是我們不知道他們都内部都是什麼内容,特别是還未被挂載到Linux下的分區。
2.對于Linux下已經挂載的分區資訊可以通過df來實作,如:
[email protected]:~$ df -l
檔案系統 1K-塊 已用 可用 已用% 挂載點
/dev/sda9 52741684 8516028 41546516 18% /
udev 914708 8 914700 1% /dev
tmpfs 368792 816 367976 1% /run
none 5120 0 5120 0% /run/lock
none 921976 512 921464 1% /run/shm
/dev/sda8 1968400 59956 1808452 4% /boot
3.為了知道,我們沒有被挂載到Linux下的分區是哪個,我們可以檢視其盤符:
[email protected]:~$ blkid
/dev/sda1: UUID="D058935E58934260" TYPE="ntfs"
/dev/sda5: LABEL="TOOLS" UUID="4E80B0D06C979E44" TYPE="ntfs"
/dev/sda6: LABEL="DATA" UUID="B0A18DDEEC101C79" TYPE="ntfs"
/dev/sda7: LABEL="BACKUP" UUID="02F5A88B6AC74F10" TYPE="ntfs"
/dev/sda8: UUID="37c4202d-0086-40e1-970f-bd7031b23ee8" TYPE="ext3"
/dev/sda9: UUID="31c15e14-cbf0-4507-8383-4150a396c45d" TYPE="ext3"
/dev/sda10: UUID="f0897643-69cf-40fa-afac-0183a27edb10" TYPE="swap"
其中“LABEL”就是對應的盤符資訊。而“TYPE”則是檔案系統的名字。如果我們想将TOOLS盤挂載到Linux下,就需要使用挂載指令。
4.挂載相應的分區
[email protected]:~$ sudo mount /dev/sda5 ./NTFS
這時/dev/sda5這個盤,也就是TOOLS盤就被我挂載到了./NTFS目錄下了。檢視:
[email protected]:~$ cd ./NTFS
[email protected]:~/NTFS$ ls -l
總用量 1897820
drwxrwxrwx 1 root root 4096 12月 18 21:12 ***
drwxrwxrwx 1 root root 8192 6月 8 20:13 ******
drwxrwxrwx 1 root root 4096 6月 10 19:21 *
drwxrwxrwx 1 root root 4096 5月 23 09:10 ***
drwxrwxrwx 1 root root 4096 6月 11 21:42 *****
drwxrwxrwx 1 root root 8192 1月 28 22:28 ****
drwxrwxrwx 1 root root 0 10月 16 2012 ***********
-rwxrwxrwx 1 root root 1943207936 10月 16 2012 ****
drwxrwxrwx 1 root root 81920 6月 13 05:39 *****
drwxrwxrwx 1 root root 0 10月 16 2012 ****
drwxrwxrwx 1 root root 0 1月 13 2012 ********
drwxrwxrwx 1 root root 0 3月 28 14:03 ****
drwxrwxrwx 1 root root 0 5月 31 15:21 *
drwxrwxrwx 1 root root 16384 5月 23 10:33 **
drwxrwxrwx 1 root root 8192 5月 23 10:08 **
drwxrwxrwx 1 root root 0 5月 23 08:46 ***
drwxrwxrwx 1 root root 16384 6月 7 15:41 ********
drwxrwxrwx 1 root root 4096 5月 23 08:55 **
這時候它就被挂載到了./NTFS目錄下了。而我們可以通過umount解除安裝該分區:
5.分區解除安裝
[email protected]:~$ sudo umount /dev/sda5
[email protected]:~$ cd NTFS
[email protected]:~/NTFS$ ls -l
總用量 8
drwxrwxr-x 2 david david 4096 6月 13 11:21 Input
drwxrwxr-x 2 david david 4096 6月 13 11:21 Output
可以看到上文NTFS中的檔案被移除了,而留下了原本在NTFS中的檔案内容。
PS:fdisk,mount,umount這幾個示例都是需要root權限才可以操作的!!!blkid 在14.04中也需要根權限才能顯示結果。