Linux使用技巧1--挂载U盘和Windwos分区


一、挂载U盘

现在我用的Ubuntu12.04在插入U盘时会直接挂载到/media/下,
10:33linc@Linc-Ubuntu:linc$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc        947M  638M  310M  68% /media/72D2-11E2
/dev/sdb        5.0G  1.5G  3.5G  31% /media/8221-13E3
但老古董如我的Fedora14却不会这样,所以我只有手动将其挂到/mnt/usb/下。
以我的三星手机为例,过程如下:

1.连上数据线,查看系统是否识别:

10:31linc@Linc-Ubuntu:linc$ lsusb
Bus 001 Device 004: ID 04e8:681c Samsung Electronics Co., Ltd Galaxy Portal/Spica/S

2.fdisk查看磁盘名称

10:32linc@Linc-Ubuntu:linc$ sudo fdisk -l
...
Disk /dev/sdb: 5354 MB, 5354029056 bytes
165 heads, 62 sectors/track, 1022 cylinders, total 10457088 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 993 MB, 993001472 bytes
31 heads, 62 sectors/track, 1009 cylinders, total 1939456 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
从结果看出,手机有两个磁盘,一个手机自带的存储,一个是外加的SDCard。

3.mount

创建目录来放置挂载的文件
sudo mkdir /mnt/usb
挂载:
sudo mount /dev/sdc /mnt/usb/
完毕!

二、挂载Windows分区

原理同上,只不过我们要找到Windows分区的磁盘名,如下:
11:24linc@Linc-Ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0xf1eff1ef

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   204812684   102406311    7  HPFS/NTFS/exFAT
Partition 1 does not start on physical sector boundary.
/dev/sda2       204812746  1953523711   874355483    f  W95 Ext'd (LBA)
Partition 2 does not start on physical sector boundary.
/dev/sda5       204812748   724724279   259955766    7  HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6       724725760  1933993983   604634112   83  Linux
/dev/sda7      1933996032  1953523711     9763840   82  Linux swap / Solaris
HPFS/NTFS/exFAT的两个device就是Windows的分区,将其中一个mount进来也同U盘一样,
sudo mount /dev/sda5 /mnt/win
sudo umount /mnt/win/
开机自动挂载

我们只需要在修改/etc/fstab文件即可,添加如下内容:

#for the windows
/dev/sda5     /mnt/win auto defaults 0 1 


三、格式化U盘

格式化成Windows能够识别的格式,用fat吧。命令如下:

$ sudo fdisk -l
...
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          32    31948799    15974384    c  W95 FAT32 (LBA)

$ sudo umount /dev/sdb1

$ sudo mkfs -V -t vfat /dev/sdb1
mkfs (util-linux 2.20.1)
mkfs.vfat /dev/sdb1 
mkfs.fat 3.0.26 (2014-03-07)


你可能感兴趣的:(Linux)