Debugging experience-hard drive and USB flash drive, debugging experience --
Debugging experience-hard disk and USB flash disk
With the development of embedded device functions, there is also a need for storage devices: the need to save a large amount of data information, the need for data transfer, and U disk upgrade functions.
When using storage devices, we encountered some problems and summarized some experiences:
1. Several Common hard disk commands
2. Hard Disk Information Analysis
3. Analysis of Causes of failed USB flash drive upgrade
4. The partition recognized by the USB flash drive is changed to/dev/sda.
I. Several Common hard disk commands
Hard Disk Partition: fdisk/dev/hda (np1 w)
Format the hard disk: mkfs. ext2/dev/hda1
Set the transmission mode of UDMA 6: hdparm-XI/dev/hda
View hard disk information: smartctl-a/dev/hda
Mount the hard disk: mount/dev/hda1/mnt/hda1
Fix the hard drive in ext format: e2fsck-y/dev/hda1
View super block information: tune2fs-l/dev/hda1
Replace 1 k of data on the hard disk: dd if =/dev/hda1 bs = 1 k skip = 131072 count = 1 of =/dev/hda1 seek = 1
View the super block backup location: mke2fs-n/dev/hda1
View hard disk details (all): dumpe2fs/dev/hda1 | less
Ii. Hard Disk Information Analysis
After mounting a hard disk, you can use fdisk-l to view the following information after the system starts identification. How can this problem be explained?
Disk/dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
This is actually a 255 GB Seagate hard disk with 60801 heads. Each head manages 512 cylinders, 63 slices per cylinder, and bytes per slice. (CHS)
How to calculate the total capacity? As follows:
255*60801*63*512 = 500107862016 = 500G
After partitioning and formatting, view the partition information as follows:
Partition command (only one partition ):
Fdisk/dev/hda (d, n, p, 1, enter, enter, w ,)
Format command (ext2 format ):
Mkfs. ext2/dev/hda1
Run the following command to view the partition information:
Dumpe2fs/dev/hda1 | less
Dumpe2fs 1.41.11 (14-Mar-2010)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: fbd1f044-491b-4cda-aaf1-a89c7bdc2726
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: filetype sparse_super
Default mount options: (none)
Filesystem state: not clean with errors
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 61063168
Block count: 122096000
Reserved block count: 6104800
Free blocks: 120076967
Free inodes: 61061072
First block: 0
Block size: 4096
Fragment size: 4096
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Thu Jan 1 08:01:35 1970
Last mount time: Wed Dec 1 10:04:11 2010
Last write time: Thu Jan 1 08:00:35 1970
Mount count: 586
Maximum mount count: 37
Last checked: Thu Jan 1 08:01:35 1970
Check interval: 15552000 (6 months)
Next check after: Tue Jun 30 08:01:35 1970
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Default directory hash: tea
Directory Hash Seed: dea4f717-12bc-4cfb-b26c-50b95411a974
Group 0: (Blocks 0-32767)
Primary superblock at 0, Group descriptors at 1-30
Block bitmap at 31 (+ 31), Inode bitmap at 32 (+ 32)
Inode table at 33-544 (+ 33)
32210 free blocks, 16365 free inodes, 2 directories
Free blocks: 551-4095,409 7-10239,102 41-18431,184 34-22527,225 30-28671,286 73-32767
Free inodes: 20-16384
The file magic number indicates the file system format. Filesystem magic number: 0xEF53 indicates ext2 or ext3.
Block Size: 4096 bytes
Inode size: 128 bytes
Each block group contains 32768 blocks.
Backup location of Superblock (in block): 32768 × N
Where N is the power of 3, 5, and 7 (N = 81,125,243,343,625,729,218, 3125)
Iii. Analysis of Causes of failed USB flash drive upgrade
Reasons for upgrading the USB flash drive:
The device provides a usb interface, which is usually not used. It is only used when data needs to be exported. Because the software always needs to be upgraded, in addition to the usual remote network upgrade, a USB flash disk upgrade is provided. The USB flash drive upgrade is not only safe and fast, but also makes up for the upgrade problem when the network is disconnected. It also relies on fewer running programs and can solve some of the more basic running problems.
USB flash drive upgrade process:
Plug in the USB flash drive and restart the device. During the boot process, there is a boot script to check whether there is a USB flash drive and determine whether there is an upgrade file in the USB flash drive. If an Update file exists, update the file. After the upgrade, the device restarts again to run the upgraded program.
Possible causes of failure in upgrading a USB flash drive:
1. the USB flash drive cannot be identified;
2. The device name recognized by the USB flash drive does not match the device name in the startup script;
-Some problems are solved by adding a supplement in the startup script to support/dev/sda4,/dev/sda1,/dev/sda.
3. The flash is full, and the program cannot be copied.
-Some problems can be solved by deleting several log files before the upgrade.
There was also a strange phenomenon:
1. programs on the device cannot always run;
2. the USB flash drive cannot be upgraded.
Solution:
1. View error information
/Etc/rcS. d/S03udev: line 52: can't create/tmp/uname: No space left on device
That is, an error has occurred in the system startup script.
2. Try to bypass S03udev.
After the system starts "Freeing init memory", Press ctrl C until "login:" appears :"
3. Enter root Login
At this time, another problem occurs: root Login fails, and an error is returned:
Unable to determine your tty name.
Modify the uboot STARTUP configuration: replace noinitrd with init =/sbin/init,
You can log on.
4. view the usage of the file system space and use df.
It is found that the usage reaches 99%.
Run the command "du-d 1" in the root directory to check which directory occupies too much space and clean it up.
5. After the space is cleared, the problem is solved and the USB flash drive can be upgraded normally.
6. When an S03udev error occurs multiple times, track the error statement and comment it out. The original file will be overwritten in the next update.
4. Change the partition recognized by the USB flash drive to sda.
Because the first batch of purchased USB flash drives are on the device by default/dev/sda, the upgrade script also determines whether the USB flash drive has been identified based on whether the device file exists. However, most of the USB flash disks purchased later and those used by others are not. The following situations are found:
Most are identified:
One device:/dev/sda
One partition:/dev/sda1
The second case is:
One device:/dev/sda
One partition:/dev/sda4
Case 3:
Device and partition coincidence:/dev/sda
After finding this problem, we modified the U disk detection judgment and considered the three cases. However, there is a problem. Some early devices decided that the USB flash disk was still dependent on/dev/sda, and the first batch of USB flash disks were not easy to find, you need to convert other types of USB flash drives to this situation. After some tests, you can find the method by performing the following steps:
1. in linux, fdisk deletes all partitions, saves and exits;
2. Force format sda: mkfs. vfat/dev/sda-I; then sda is available.
How to use a USB flash drive to partition a hard drive on a computer Baidu experience
After purchasing a computer, we usually find that there are only two disks: Drive C and drive D. These two disks have a large capacity and are usually partitioned for ease of use. Many friends may think that partitioning is a complicated technical activity, but it is actually not. Today's WIN7 system comes with a partitioning tool, so you can use this tool to easily partition. Next, we will teach you how to encrypt the USB flash drive.
Right-click my computer and select the "manage" command. In the open "Computer Management" form, expand "Computer Management"> "Storage"> "disk management" in sequence. Then, you can see the partition of the current hard disk in the right pane. Right-click a disk space not assigned and select the "Create disk partition" command. In the displayed disk partition wizard, select "extended partition" as the partition type, click "Next", and enter the capacity of the new partition, then, set the disk file format for the partition, and check "do not format". Then, click "finish" to complete the partitioning operation. Open "my computer", right-click "create partition", select the "format" command, and use the quick format method to complete all partitioning and formatting operations within 60 seconds.
What is the transmission speed of the hard disk USB flash drive?
The following conclusions are based on my years of computer experience:
1, desktop: 50 ~ 60 MB/S
2. Notes: 30 ~ 40 MB/S
3, hard shift: 30 ~ 50 MB/S
4. USB flash drive: 10 ~ 25 MB/S
5, hard: 100 MB/S