Linux挂载USB硬盘的方法
先检查Linux是否加载usb模块
lsmod | grep usb
如果没有信息,则执行
modprobe usb-storage
之后把USB的硬盘接上,执行
fdisk -l
可以看到
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 587 4610655 82 Linux swap
/dev/sda3 588 9729 73433115 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn’t contain a valid partition table
可以看到/dev/sda是我们已有的硬盘,/dev/sdb就是USB硬盘了,提示改硬盘还没有分区,接下来我们就对/dev/sdb做分区,执行命令
fdisk /dev/sdb
之后会提示
Command (m for help):
可以输入m看一下help,我们输入n,新创建一个分区,之后出现
Command action
e extended
p primary partition (1-4)
输入p,创建主分区,之后
Partition number (1-4):
输入1,会提示
First cylinder (1-121601, default 1):
直接回车,即默认1,也就是从1开始,提示
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601):
直接回车,因为我把整个硬盘分1个区,所以就用最大值,回车就可以了,提示
Using default value 121601
Command (m for help):
这时候我们可以输入p,看一下分区情况
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 121601 976760001 83 Linux
Command (m for help):
这时候输入w,写入分区表,这样就完成了,会提示
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
我们再执行fdisk -l看一下情况
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 587 4610655 82 Linux swap
/dev/sda3 588 9729 73433115 83 Linux
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 121601 976760001 83 Linux
我们已经看到/dev/sdb1了,现在要对/dev/sdb1做一下格式化,在linux上可以将格式化成多种格式,比如ext3 、reiserfs 、ext2 、fat32 、msdos等,我们还是格式化成ext3的默认格式,执行
mkfs.ext3 /dev/sdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
122109952 inodes, 244190000 blocks
12209500 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=247463936
7453 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done (在这个地方会等待,直到done)
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
直接回车就之后就完成格式化
done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
之后我们可以把/dev/sdb1挂载到系统中,比如
mount /dev/sdb1 /u02/oradata1
用df命令看一下
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 72279384 9336512 59271220 14% /
/dev/sda1 101086 8741 87126 10% /boot
none 1553948 0 1553948 0% /dev/shm
/dev/sdb1 961432072 110656 912483416 1% /u02/oradata1
/dev/sdb1已经mount到/u02/oradata1了。