Hot answers tagged

59

You still need to create a file system mkfs.ext4 /dev/sdb1 Parted User's manual https://www.gnu.org/software/parted/manual/html_node/mkpart.html: 2.4.5 mkpart Command: mkpart [part-type fs-type name] start end Creates a new partition, without creating a new file system on that partition.


35

create a partition using fdisk fdisk /dev/sdx Commands: to create the partition: n, p, [enter], [enter] to give a type to the partition: t, 7 (don't select 86 or 87, those are for volume sets) if you want to make it bootable: a to see the changes: p to write the changes: w create a ntfs fileystem on /dev/sdx1: mkfs.ntfs /dev/sdx1 mount it wherever you ...


33

The entries in /dev/mapper are LVM logical volumes. You can think of these as Linux's native partition type. Linux can also use other partition types, such as PC (MBR or GPT) partitions. Your disk is divided in MBR partitions, one of which (/dev/sda2) is an LVM physical volume. The LVM physical volume is the single constituent of the volume group ...


31

I just did this in an easier way: # sfdisk -d /dev/sdb > sdb.bkp leave a copy for safety # cp sdb.bkp sdb.new now edit sdb.new changing ONLY the lines order and partition numbers, as in my case: from # partition table of /dev/sdb unit: sectors /dev/sdb1 : start= 1026048, size=975747120, Id=83 /dev/sdb2 : start= 2048, size= 204800, Id=83 /...


26

According to the documentation for the queue sysfs files: # cat /sys/block/sda/queue/hw_sector_size 512


23

Will dd if=/dev/zero of=/dev/sda wipe out a pre-existing partition table? Yes, the partition table is in the first part of the drive, so writing over it will destroy it. That dd will write over the whole drive if you let it run (so it will take quite some time). Something like dd bs=512 count=50 if=/dev/zero of=/dev/sda would be enough to overwrite the ...


22

Use fdisk for drives that are < 2TB and either parted or gdisk for disk > 2TB. The actual difference has to do with the partitioning formats that these tools are manipulating. For disks < 2TB you're often using MBR (Master Boot Record). For disks > 2TB you're using GPT (GUID Partitioning Table). Here's a good article that covers the differences as ...


16

The primary reason to use gparted or parted is if the new disk is bigger than 2TB. But you probably will not be able to effectively set that up from a 32 bit system. If you want to run the new disk from your old system. Stay with a disk smaller than 2TB. You should be able to partition, format and run that from you old computer using fdisk for partitioning. ...


15

When setting up a disk or partition there are 2 aspects to doing this. The first is the act of laying down a partition table scheme on the disk using typically either MBR (Master Boot Record) or GPT (GUID Partitioning Table) formats. Both of these lay down a "structure" on the disk. MBR If you take a look at the structure of an MBR you'll notice that ...


14

Steps taken according to Gilles' answer: $ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 9.8 GiB, 10485760000 bytes, 20480000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/...


14

The head, cylinder, sector numbers are displayed for historical purposes only, and for use by some really old software. Logical Block Addressing is used to address disks today. The geometry of modern disks typically have a variable number of sectors, outer tracks have more sectors than inner tracks. Various interfaces have maximum values of 255 heads, 63 ...


13

-rw-r--r-- 1 root root 10485760 Mar 3 22:04 /dev/sdb /dev/sdb is a regular file, not a device. You must have run rm /dev/sdb at some point. It is created automatically when the device is inserted, but when you run commands as root, you can mess up with it. Now that /dev/sdb is a regular file, it's stored in memory, on a filesystem which has a low size ...


12

The symlinks under /dev/disk/by-uuid/ are created by udev rules based on filesystems UUIDs. If you look at /usr/lib/udev/rules.d/60-persistent-storage.rules you will find entries like: ...... ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" To reference a disk you could use the disk serial number and the ENV{ID_SERIAL_SHORT} key. The ...


12

Looks like this device is mounted. Run umount /dev/sdb1 and try again.


11

The culprit is not less, but fdisk: Many programs only color their output when they print to a terminal, and don't color it when the output is redirected, because in general you want to avoid breaking scripts with the ESC-codes used for colors. However, usually these programs also have switches to manually turn on coloring. So try sudo fdisk --color=always ...


10

In your configuration you allowed: userA to run any command as any user userB to run fdisk as vinoth fdisk by default requires root privileges to access the devices, you cannot run it as userA, ie. you can run, but fdisk -l will print no output, which is what you got. Finally sudo command is not transitive. When you execute a command from userB account ...


10

In the normal interface, Linux's fdisk applies alignment constraints to partitions. Which constraints depends on the version of fdisk. Older versions defaulted to cylinder alignment, for compatibility with older operating systems that were incompatible with LBA. When LBA was a little over two decades old, fdisk stopped catering for such ancient systems by ...


10

I have had this issue in the past. IIRC, "Offline uncorrectable sectors" means that the disk controller (the one inside the disk, not the SATA/SCSI controller in your PC) has had repeated read failures with one sector and has decided that it was definitely not usable. So, I must declare that sector as bad to the filesystem that uses it? No. Fortunately, ...


10

The partition table is stored near the beginning1 of the (logical2) disk device. Overwriting that area with anything (zeroes from /dev/zero or any other data) will replace the partition table with gibberish, so it will no longer be obvious where the partitions on the device begin. One can still scan the whole disk and try to identify the "magic bytes" that ...


9

On Linux, traditional DOS-partitions will show up this way: Partitions from 1 to 4 are primary partitions. Partitions above 5 are logical partitions. In the DOS-partitioning-scheme (this is not Linux-specific), if you want to use logical partitions you have to define a pointer within one of the primary partitions for these. At this pointer the BIOS will ...


8

fdisk -l can just list the filesystems it has the permission to read on. See my test with strace: user@host:~/test$ strace -e open /sbin/fdisk -l ... open("/proc/partitions", O_RDONLY) = 3 open("/dev/sda", O_RDONLY) = -1 EACCES (Permission denied) open("/dev/sda1", O_RDONLY) = -1 EACCES (Permission denied) open("/dev/sda2", ...


8

You cannot use fdisk to work with GPT disks, it will only work with MBR disks. Any disk that > 2TB must be GPT. You likely cannot mount this HDD because even though the kernel has detected it (in the dmesg output) the HDD hasn't been partitioned or formatted with a filesystem so that it can be mounted. Try the following to do this: $ sudo sfdisk -l This ...


8

You do not need to create a partition table on a disk (neither the traditional kind created with fdisk nor the GPT kind created with, e.g. gdisk), you could make the whole block device into an LVM PV if you wanted to. However, other tools or other operating systems might accidentally mistake that device for an unformatted hard disk and offer to format it, so ...


8

This should be relatively easy, since you're using LVM: First, as always, take a backup. Resize the disk in Xen (you've already done this; despite this, please re-read step 1). Use parted to resize the extended partition (xvda2); run parted /dev/xvda, then at the parted prompt resizepart 2 -1s to resize it to end at the end of the disk (BTW: quit will get ...


7

@chaos and @Braiam have provided good answers on why you aren't getting the behavior you are looking for from fdisk when running as a non-root user. The simple fact is that allowing regular users to read disks directly would allow bypassing file permissions by simply reading the disk data directly, which could be a major problem and certainly would make file ...


7

In the first versions of Unix, a block was 512 bytes all the way from the hardware through the filesystem through C code to user tools. Nowadays there are many different types of hardware and many different filesystems (some of which don't have any notion of block size), so “block size” is an arbitrary definition chosen by each tool. Most traditional Unix ...


7

why can't you try df -hT? Output -bash-3.2$ df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda2 ext3 48G 17G 29G 37% / /dev/sda5 ext3 238G 66G 160G 30% /home /dev/sda1 ext3 99M 17M 77M 18% /boot tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm The type specifies the system type and the only ...


7

cfdisk is a graphical application designed to be more friendly to the novice. If you are comfortable with fdisk, then by all means, use it. If you prefer a bit more hand holding and fewer ( advanced ) options, use cfdisk. Another good alternative is GNU parted.


7

If that 65535 refers to 512-byte sectors, it would not be aligned at all. Unfortunately fdisk with dos partitions can get funny ideas about drive geometry. Ignore whatever fdisk is trying to do, just use 1MiB alignment anyway. If you don't need dos partitions for any particular reasons, switch to gpt. If fdisk doesn't work, switch to parted, gdisk, or ...


7

I had this problem with /dev/sda on Ubuntu 16.04 I solved it by booting into a live usb and doing the following: To see your disks use lsblk If you can see your drive thats good, run fdisk -l to see if the system can use it. Run this command to attempt to repair bad superblocks on the drive. fsck /dev/sda1 (replace /dev/sda1 with the drive you want to ...


Only top voted, non community-wiki answers of a minimum length are eligible