1. 对fat32 8G U盘分区。
[email protected]:~$ sudo fdisk /dev/sdb
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-15633407, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15633407, default 15633407):
Using default value 15633407
Command (m for help): p
Disk /dev/sdb: 8004 MB, 8004304896 bytes
35 heads, 21 sectors/track, 21269 cylinders, total 15633408 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: 0x7523bf12
Device Boot Start End Blocks Id System
/dev/sdb1 2048 15633407 7815680 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[email protected]:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 8004 MB, 8004304896 bytes
33 heads, 21 sectors/track, 22559 cylinders, total 15633408 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: 0x7523bf12
Device Boot Start End Blocks Id System
/dev/sdb1 2048 15633407 7815680 83 Linux
2. 对 8G U盘linux格式化。
[email protected]:~$ sudo mkfs -t ext3 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
488640 inodes, 1953920 blocks
97696 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2004877312
60 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information: done
3.挂载u盘到mnt/usb目录下,设定U盘的用户属性ftp,以便vsftpd访问。
[email protected]:/$ sudo mount /dev/sdb1 /mnt/usb
[email protected]:/etc$ cd /mnt/usb
[email protected]:/mnt/usb$ ls -al
total 28
drwxr-xr-x 4 root root 4096 Nov 17 00:33 .
drwxr-xr-x 5 root root 4096 Nov 17 00:32 ..
drwx------ 2 root root 16384 Nov 17 00:30 lost+found
[email protected]:/mnt/usb$ sudo chown ftp:ftp . -R
[email protected]:/mnt/usb$ ls -alt
total 28
drwxr-xr-x 4 ftp ftp 4096 Nov 17 00:33 .
drwxr-xr-x 5 root root 4096 Nov 17 00:32 ..
drwx------ 2 ftp ftp 16384 Nov 17 00:30 lost+found
4.卸载u盘,将u盘重新挂载到ftp目录下
[email protected]:/$ sudo mount /dev/sdb1 /srv/ftp/ftp
5. 用filezila访问即可。