Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Ubuntu mounts the file system

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains how Ubuntu mounts the file system. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "Ubuntu how to mount the file system"!

First, check the status on the Ubuntu hard drive

There are times when we need to care about what is on the hard disk and how big the files are, so here are two commands: df and du.

Df:df is used to check the disk footprint of the file system. You can use this command to get information such as how much space the hard disk is occupied and how much space is left. The parameters of df are: code:

"- a displays the disk usage of all file systems, including 0 (block) file systems, such as / proc file systems." -k is displayed in k bytes. "- I displays I node information, not disk blocks." -t displays the disk space usage of each specified type of file system. -x lists disk space usage that is not a specified type of file system (as opposed to the t option). -T displays the file system type. Explain the df command in detail:

Reference:

Dongmh@home:~$ df Filesystem 1K-Block used available mount point / dev/sda12 3842376 242424 3404764 7%

This is the most basic usage, and you may find it strange that the sum of the used and available blocks does not equal the total value of the previous block, because by default, there is reserved space for root for maintenance and management, never mind. Other uses are nothing more than adding different parameters to display different information without repeating it.

Du:du is used to count the disk space occupied by directories or files. Its parameters are as follows: code:

-s only gives the total number of blocks occupied for each Names parameter. -a recursively displays the number of blocks occupied by each file in the specified directory and in the descendant directory. If neither-s nor-an is specified, only the number of disk blocks occupied by each directory and its subdirectories in the Names is displayed. -b lists disk space usage in bytes (the system defaults to k bytes). -k lists disk space usage in 1024 bytes. -c * plus a total (the system default). -l calculates all file sizes, and for hard-linked files, calculates multiple times. -x directories skipped on different file systems are not counted.

This command is as simple as df, because of special reasons, so do not give examples, you can try it yourself, very brush the screen.

II. Ubuntu hard disk partition

On a computer with win, partitioning is undoubtedly a very simple thing. Using the partition magician, you can partition, merge and resize the hard disk, so most friends who have win on computers like me must not worry about partitioning, sort out the data, free up a few partitions, and then use the installation program to partition the Ubuntu hard disk. There will be nothing to worry about in the future, but some friends because of some needs. You must use the linux operating system for partitioning, so the following may be of some value.

First of all, let's talk about the basics. A Ubuntu hard disk can be divided into four zones, three main partitions and one extended partition, while the extended partition can be divided into n logical partitions. The extended partition itself cannot store anything, nor can it be formatted into a certain file system. It can only be used to distinguish logical partitions.

We mainly apply three commands: fdisk, cfdisk, and gparted. The first two commands have already been installed in breezy. If you need gparted, you need to install it separately. We have it in our source. Install method: code: sudo apt-get install gparted

The difference between these three software is mainly intuitive, easy to use, fdisk can be said to be the most difficult to use, while cfdisk has a character interface, gparted has a more beautiful interface based on gnome, from a functional point of view, the three software are almost the same, but sometimes have to use fdisk, here I have a certain description of the use of the three software: fdisk: code: sudo fdisk-l will list the physical usage of all hard drives. Code: sudo fdisk-l / dev/hda will list the usage of * Fast IDE hard disk. In response, you can switch to / dev/sda, and so on. Code: sudo fdisk / dev/hda

Enter the hard disk partition mode, after entering this mode, all operations will not take effect immediately, it will only take effect after the confirmed command. Code:

M displays all command prompts. P actual hard disk partition situation. A set the hard drive startup area. N set a new hard disk partition. L lists all file system types. E can only be used if you enter n, which means adding an extended partition. P can only be used if you enter n, which means adding a primary partition. L can only be used if you enter n, which means adding a logical partition. T change the hard disk partition properties. D delete the hard drive partition. Q ends without modifying the hard drive. W ends and modifies the hard drive.

Now for a detailed explanation of the results of fdisk, here is an example of running on my computer: reference:

Dongmh@home:~$ sudo fdisk-l / dev/hda Disk / dev/hda: 60.0 GB, 60022480896 bytes 255heads, 63 sectors/track 7297 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System / dev/hda1 * 1 1276 10249438 + 7 HPFS/NTFS / dev/hda2 1277 7297 48363682 + f W95 Ext'd (LBA) / dev/hda5 1277 2551 10241406 7 HPFS/NTFS / dev/hda6 2552 3835 10313698 + 7 HPFS/NTFS / dev/hda7 3836 3957 979933 + 82 Linux swap / Solaris / dev/hda8 3958 2441848 + 83 Linux / dev/hda9 4262 4869 488372883 Linux / dev/hda10 48707297 19502878 + Linux

The above prompt indicates that my Ubuntu hard drive has 60G Ubuntu 255 planes, 63 sectors, and 7297 pillars; each column capacity is 8225280 Byte, which is about 8225KB or 8MB.

Device Boot Start End Blocks Id System partition sequence boot starts terminating capacity partition type ID partition type boot represents the boot partition, in the above example hda1 is the boot partition, the first partition starts with X cylinder (magnetic pillar), the end indicates that a partition ends with Y cylinder (magnetic pillar), and then enters partition mode:

Reference:

Dongmh@home:~$ sudo fdisk / dev/hda The number of cylinders for this disk is set to 7297. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g.old versions of LILO) 2) booting and partitioning software from other OSs (e.g.DOS FDISK, OS/2 FDISK) Command (m for help):

The above tip roughly means that my Ubuntu hard drive is larger than 1024 magnetic columns, so my boss Ben's lilo will not buy me, so you don't have to worry about it. Let's try to command d first.

Reference:

Command (m for help): d Partition number (1-10):

It asks which partition you want to delete, you must pay attention to, if you delete the extended partition, then all logical partitions are linked together, you must be careful. I type 7 and then p to see that my Ubuntu hard disk partition is missing.

Next I'll add a logical partition: reference:

Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (3836-7297, default 3836): 3836 Last cylinder or + size or + sizeM or + sizeK (3836-3957, default 3957): 3957

The two questions here are which is the starting column and which is the ending column. You can enter it with + sizeM + sizeK at the end of the column. Then there is the change to the partition type, and I type t:

Reference:

Command (m for help): t Partition number (1-10): 7 Hex code (type L to list codes): l

Enter L to see a list of file type columns for all disks, and then change the partition file system by entering the corresponding file system ID. * enter w if you need to save it, and Q if you don't want it, so that the partition modification is over.

Cfdisk and gparted:cfdisk have very intuitive interfaces, while gparted is even in Chinese, so I'm not going to introduce them here.

III. Ubuntu hard disk formatting

The division is not done yet, and it can only be used normally after formatting. Here is an introduction to the Linux formatting command: code: sudo mkfs-t file system storage device formatting is that simple, or you can enter the command: code:

Sudo mkfs.ext3 / dev/sda6 formats the device into an ext3 file system. Sudo mke2fs-j / dev/sda6 formats the device into an ext3 file system. Sudo mkfs.ext2 / dev/sda6 formats the device into an ext2 file system. Sudo mke2fs / dev/sda6 formats the device into an ext2 file system. Sudo mkfs.reiserfs / dev/sda6 formats the device into a reiserfs file system. Sudo mkfs.vfat / dev/sda6 formats the device into a fat32 file system. Sudo mkfs.msdos / dev/sda6 formats the device into a fat16 file system, which is fat16. Sudo mkdosfs / dev/sda6 formats the device into a fat16 file system, and mkfs.msdos sudo mkswap / dev/sda6 formats the device into an swap file system.

In this way, the zone is divided, and the formatting is finished, and you can mount it.

4. Mount the file system on Ubuntu hard disk

There are two ways to mount a file system, one is to use the mount command, and the other is to modify / etc/fstab, because it is not convenient to modify / etc/fstab, so I only introduce mount. The mount command is used as follows:

Code: sudo mount [- t file system] [- o option] device directory

Before using this command, you need to make a directory for hanging. After creating such a directory, there is a detail problem is to change the permissions of this directory, at least you can read and write, so that your mounted hard disk can read and write, except for ntfs's hard disk. Code: chmod 777 directory

When mounting, there are also places where you can save trouble. For example, if you don't know what file type your partition is, you can: code: sudo mount-t auto device directory or you can also: code: sudo mount device directory. By the way, swap partition is not mounted in this way. Instead, load command is used to load: code: sudo swapon device is generated accordingly: code: sudo swapoff device.

5. Ubuntu hard disk scans the file system

Friends are not familiar with scandisk in Windows. There is a tool like fsck in Linux, but fsck can not only scan, but also fix some problems with the file system. It is important to note that when fsck scans the file system, it must be done after repairing the mode or umount the device, otherwise there will be major problems.

Fsck supports file system ext2 by default. If you want to support ext3 file system scanning, you should add the-j parameter. * We should call different scanning tools according to different file systems, such as fsck.ext2,fsck.jfs,fsck.msdos,fsck.ext3,fsck.reiserfs. There are several common parameters for fsck.ext2 and fsck.ext3, as follows: code:

-p automatically fixes problems with the file system;-y prompts if there is a problem with the file system, press y;-c to check the bad blocks of the file system; this is a very long process;-n does not make any changes to the file system, just scan to see if there is a problem

Then the way to use it is: code: sudo fsck.ext3-p / dev/hda6 any Ubuntu hard disk operation is dangerous, do not practice casually, try to use gparted with interface when possible, and don't format it casually unless you have to. This is for the sake of your data and the life of your Ubuntu hard drive.

At this point, I believe you have a deeper understanding of "Ubuntu how to mount the file system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report