Linux mount U disk

  

Before hanging the u disk, run the command cat /proc/partitions to see which partitions are in the system. After plugging in the u disk, run the above command again to see what partitions are available (usually sda1, PS is installed in the virtual machine, so it is sdb1).

1, insert U disk< Br>

2, enter fdisk -l /dev/sda to view the output, such as mine: # fdisk -l /dev/sdaDisk /dev/sda: 131 MB, 131104768 bytes3 heads, 32 sectors/track , 2667 cylindersUnits = cylinders of 96 * 512 = 49152 bytes

Device Boot Start End Blocks Id System/dev/sdb1 * 1 2668 128016 6 FAT16

3, read the above output to know The device where the USB flash drive is located, for example, I am /dev/sdb1, and then it is mounted. Suppose I mount the USB flash drive to the /mnt/usb directory (no, new), which is mount -t msdos /If dev/sdb1 /mnt/usb is fat16, use the following command mount -t msdos /dev/sdb1 /mnt/usb If it is fat32 mount -t vfat /dev/sdb1 /mnt/usb If it is ext2 format, use the command :mount -t ext2 /dev/sda1 /mnt/usb

4, open /mnt/usb to see what's in your USB flash drive! Cd /mnt/usb

Specific commands: 1. Add FAT32 file system

The simplest usage mount /dev/hda6 /mnt/d

/dev/hda6 Is the author of the Windows
D drive, /mnt/d is the directory plus point. Linux will recognize what the file system type of the /dev/hda6 partition is and then add it. Of course, you can also specify the file system type of the partition, the command is as follows:

mount -t vfat /dev/hda6 /mnt/d

In the actual operation, directly add a windows partition , Chinese file names and directory names will be garbled, in order to avoid this situation can specify the character set, the command is as follows:

mount /dev/hda6 /mnt/d -o codepage=936,iocharset=cp936mount -t Vfat /dev/hda6 /mnt/d -o codepage=936,iocharset=cp936

Note: cp936 refers to Simplified Chinese, and cp950 refers to Traditional Chinese.

2.Adding NTFS file system

On most current Linux versions, you need to recompile Linux kernels and add NTFS partitions (see other articles for compiling methods). After the core supports NTFS, you can use the following command to add:

mount -t ntfs /dev/hda2 /mnt/c

The same problem can occur for Chinese file names and directory names. Specify the character set, but unlike the vfat partition, it is possible to use the following command:

mount -t ntfs -o iocharset=cp936 /dev/hda2 /mnt/c -rmount -t ntfs - o iocharset=cp936,rw /dev/hda2 /mnt/c

3.Adding a file system on a USB flash drive

There are more and more people using U disk now, actually U disk is also very simple under Linux. Linux has good support for USB devices. After you insert a USB flash drive, the USB flash drive is recognized as a SCSI disk. Usually you can use the following command to add the file system on the USB flash drive. Mount /dev/sda1 /usb

The same problem can be specified for Chinese file names and directory names. The command can be similar to the above description for FAT32: mount /dev/sda1 /usb -o Pagecode=936,iocharset=cp936

4.Adding a directory that Linux system shares through samba

Using samba to share the directory is actually hard to say which file system it is. But this is not important, as long as it is transparent to users thousand million. When adding, we specify the type as smbfs. When adding the partition shared by samba, the Chinese file name and directory name will be garbled. You can use the following command to add:

mount -t smbfs -o Username=terry,password=terry,codepage=936,iocharset=cp936//terry-linux/terry/mp3/mount -t smbfs -o username=terry,password=terry,codepage=936,iocharset=cp936//192.168. 100.228/terry /mp3/

Note: You can not directly write the password=terry parameter, the system will ask you to enter the password, so you can prevent someone from directly seeing your password. Depending on the situation, the parameters after -o can be increased or decreased.

5.Adding the directory shared by the Window system

In the LAN, it is often necessary to access the directories shared by other Windows systems. Under Linux, you can use samba after installing samba. The command in the middle comes to access the shared resources of the Windows machine.

Use smbclient to list shared resources of Windows machines

smbclient -L 192.168.100.111

According to the shared resources of Windows listed above, you can choose to add To the shared resources of Windows in the local Linux, and then use smbmount or mount to add, please refer to the following commands:

smbmount //192.168.100.111/public /public/mount //192.168.100.111 /d /mnt/cdrom -o username=terry (so you want to enter the password on the command line) mount //192.168.100.111/d /mnt/cdrom -o username=terry$1234 (so you don't have to enter the password on the command line) Br>

Note: In addition to the command line methods described above, the best way to do this is to use other clients, such as LinNeighborhood, networkneighbours, ksmbshare, etc. Please refer to other articles.

The above is the command line method, you must enter it once every time you use it. If you often want to add some file systems, what should you do if you want to automatically add it at startup? Here are two ways to do this:

Method 1. Put the attached command in /etc/rc.d/rc.local.

Method 2. Modify the partition configuration file /etc/fstab, add the file system at startup, the following is my /etc/fstab file: LABEL=//ext3 defaults 1 1none /dev/pts devpts gid =5,mode=620 0 0LABEL=/home /home ext3 defaults 1 2none /proc proc defaults 0 0none /dev/shm tmpfs defaults 0 0/dev/hda4 swap swap defaults 0 0/dev/cdrom /mnt/cdrom iso9660noauto, Owner,kudzu,ro 0 0/dev/hda2 /ntfs ntfs defaults,iocharset=cp936 0 0/dev/hda6 /win vfat defaults,codepage=936,iocharset= cp936 0 0//192.168.100.228/terry /mp3 smbfs username =terry,password=terry,codepage=cp936,iocharset=cp936 0 0

Please note the last three lines:

the last line of the countdown, add my C drive, the countdown of NTFS format The third line, add my D drive, the penultimate line of the FAT32 format, and add a directory on another Linux server on my LAN that installs samba.

All of the above commands must be executed as root

Copyright © Windows knowledge All Rights Reserved