date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,580,829,756,000 |
How can i create gpt marks on working system.
NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
ad4p3 ONLINE 0 0 0
ad6p3 ONLINE 0 0 0
I want ad4p3 to disk0 and ad6p3 to disk1
NAME ... |
You can either use gpart or glabel.
As you've already created the partitions, gpart modify -i <index> -l diskX is probably the best way to do it.
Be aware that with ZFS on FreeBSD you'll have to refer to these as gpt/disk0 and gpt/disk1, not just disk0 and disk1.
I'd suggest:
removing one half of the mirror from the ... | FreeBSD zfs create gpt |
1,580,829,756,000 |
I am trying to create a swap partition in my script using parted based on the Arch Linux guidance.
https://wiki.archlinux.org/title/Parted#Partition_schemes
Somehow it is always sort of skipping the file system type and instead using it as partition label.
Running parted manually creates the correct filesystem, linux-... |
You cannot create swap space within the parted command. You can set up the partition label to indicate that it is swap but it isn't really:
dd bs=1M count=100 if=/dev/zero >/tmp/100m.img
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.687057 s, 153 MB/s
lo=$(losetup --show --find ... | parted: create swap partition on gpt disk (one liner) not working |
1,580,829,756,000 |
In the last 2 months, I have installed Linux Mint 19.1 on two laptops. On the older of the two, a Samsung Rv511 (ca. 2011) using MBR partitioning, there have been no problems at all. Linux Mint has worked very well.
With a 2018 HP Pavilion with UEFI and GPT partitioning, the reverse has been true. Linux Mint crashe... |
*fsck failed with with exit status 4.
Exit status 4 from the fsck command means "filesystem contains errors that could not be corrected".
*Failed to start File System Check on /dev/disk/by-uuid/2ad686b0-e77b-47da-bb44-5934b5fa6541.
And on another filesystem, the filesystem check did not even start successfully.
The... | On UEFI laptop, Linux Mint has crashed twice |
1,580,829,756,000 |
On my Debian 8 server HDD /dev/sda crashed. mdadm informed me via email and I had the disk replaced.
After the server was back up I copied over my GPT from using sgdisk -R /dev/sdb /dev/sda. The second I hit "Enter" on my keyboard I realized my mistake.
So now I have an empty GPT on both disks.
My question is if it i... |
After researching a bit and after trying out tools such as testdisk, I did not find a defintive way to restore my original GPT on /dev/sdb
So I tried using cgdisk and it was successfull, as I still had the original "sector layout" of /dev/sdb noted down:
Disk identifier: 9F95A04D-3ECB-144D-B2A0-55CDD986072B
Device ... | (Re-)Create GPT from existing partitions on Debian 8 |
1,580,829,756,000 |
We have a Centos server as a virtual machine where the / path is getting full.
So we want to resize the partition from 50GB to 70GB.
I followed this guide
https://www.thomas-krenn.com/de/wiki/LVM_vergr%C3%B6%C3%9Fern
So the first step was to increase the size in the VM preferences.
After this I used cfdisk to create a... |
Resize an LVM partition on a GPT drive
Commands:
pvs Shows physical volume
lvs Shows logical volume
vgs Shows volume groups
vgdisplay Shows volume groups including mount points
lsblk Shows block hierarchy (plate, partition, LVM)
The basic flow of necessary steps is essentially:
Resize... | Resize an LVM partition on a GPT drive |
1,580,829,756,000 |
I know it's up to 128 for windows OS. Does the same limit apply to Linux? So this limit is actually a limit of GPT?
|
The Windows FAQ on this says
The specification allows an almost unlimited number of partitions. However, the Windows implementation restricts this to 128 partitions. The number of partitions is limited by the amount of space reserved for partition entries in the GPT.
so the 128 is Windows-specific.
For Linux, as exp... | How many partitions can be created for linux on GPT? |
1,580,829,756,000 |
I want to dual-boot Arch Linux alongside Windows 10, which is already installed.
I am using UEFI-GPT.
On Windows 10 installation, it creates an EFI system partition as required by UEFI. This partition's capacity is 100 megabytes. On the Arch Linux installation guide listed on the Arch Wiki, it displays that I need to ... |
If Arch's filesystem layout only places grubx64.efi (and possibly the GRUB2 configuration file) to the EFI partition, 100 MB is fine.
But if your layout mounts the EFI partition as /boot (rather than /boot/efi) or otherwise causes the entire kernel + initramfs files to be placed in there, you might run out of space wi... | Am I able to install Arch Linux with the 100MB EFI partition that Windows 10 had already created on installation? |
1,580,829,756,000 |
Are timestamps created with new GPT partition tables?
If so, where are they (i.e, headers, entries, GUIDs, labels)? How are they accessed?
|
There aren’t necessarily any timestamps created with new GPT partition tables. The GPT layout doesn’t include any timestamp fields. If a partition is given a version 1 GUID (see RFC-4122 sections 4.1.3 and 4.1.4), the generated GUID will include a timestamp; but any other version won’t. Most partition GUIDs I’ve seen ... | Are timestamps created with new GPT partition tables? |
1,580,829,756,000 |
I have an issue very similar to the question here:
https://askubuntu.com/questions/1370421/restore-ext4-hd-after-creating-gpt-partition-table
My problem seems to be that I had an ext4 filesystem which sat directly on a block device, and installing windows to an entirely different drive decided to mess with that device... |
It's not possible (that way).
You can't have a partition table, and a filesystem, on the same block device.
When you create a partition on /dev/nvme1n1, it gives you a new block device /dev/nvme1n1p1 — you have to use the new block device for the filesystem.
And that means shifting all data by the partition offset. Ke... | Fixing an ext4 whole-device filesystem and corrupt GPT partition table |
1,580,829,756,000 |
I use msdos partition table, so there is no PARTUUID supported (it's only on GPT partition tables)
root@xenial:~# fdisk -l
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 51... |
Looks like the PARTUUID on a MBR-partitioned disk is the Windows Disk Signature from the MBR block (8 hex digits) + a dash + a two-digit partition number.
The Windows Disk Signature is stored in locations 0x1B8..0x1BB in the first block of the disk (the MBR block), in little-endian byte order.
This command will displa... | What is PARTUUID from blkid when using msdos partition table? |
1,580,829,756,000 |
I have a 4-way mirrored rpool on a set of GPT disks running Solaris 11.3 (GPT being used as the disks are more than 2TB in size) on x86 hardware.
Disks 1 and 2 are the "main" operating system. Disks 3 and 4 are intermittently present as they are offsite (offline) backup disks (which automatically update their data wh... |
Managed to sort it in the end but not quite the way intended, although probably easier in the long run.
I first used:
bootadm install-bootloader
which ensures all the disks boot.
The BIOS then has a disks section which looks like a lists of disks it allows to be used. The list is however a list of disks it boots fro... | Wiping the boot partition of a GPT disk in Solaris 11.3 |
1,580,829,756,000 |
So I'm having a problem with kimsufi server. I was installing windows by using this command:
wget -O- ...url.../server.gz | gunzip | dd of=/dev/sda
And I messed up and accidentally ran that command on already existing windows installation, now I can't use RDP anymore, I guess it's all gone now, it somehow wrote over ... |
I recovered the partly overwritten partition with testdisk. In case someone has the same problem, here's the solution (use testdisk):
Intel/PC Partition >
Analyse >
Quick search >
And there I found the deleted partition [1.8 TB] >
Enter to continue >
[Write] (Write partition structure to disk) >
And now the partit... | How to recover overwritten partition? |
1,580,829,756,000 |
I have 480 GB SSD it currently has the following partitions 256MB EFI partition, 16GB SWAP, and 40GB CentOS 7 see details from lshw below. I want to use the remaining 400GB of unused space on the drive as an iSCSI target. The system only has /dev/sda1, /dev/sda2, /dev/sda3, there is no /dev/sda4 mapped to the 400GB o... |
The first step is to create a partition. There's no entry in /dev for the free space because it's free space, not a partition.
You can use fdisk to create a partition. Run fdisk /dev/sda, then enter the n command and create a partition covering the free space. Once you're satisfied with the new partition table, enter ... | Create a GPT partition covering the free space |
1,580,829,756,000 |
I have a laptop, which has a 500GB hard disk and with MBR partition, and I install my windows8.1 on it, but I left ~75G unused which I would like to use it for OpenSuse13.1. Now I have 2 USB, one is Gnome Live 13.1, another is standard DVD install ISO.
I tried to insert Gnome live 13.1 and no problems, it recognized m... |
It sounds like you're either booting Windows 8.1 in legacy/BIOS/MBR mode (as opposed to EFI/GPT mode), or YaST is buggy and thinks that you have EFI booting enabled even though you don't. Another possibility is that your laptop's BIOS boots optical drives in EFI mode by default, causing YaST to load in EFI/GPT-only mo... | How to install after windows 8.1 with MBR partition |
1,580,829,756,000 |
I'm trying to install grub but I'm getting the error:
Warning This GPT partition label contains no BIOS boot partition:
embedding won't be possible
I'm using GPT to partition, and the file system is ext3. When I ran gdisk -l it shows the first partitions start sector on the SSD (which is /sda) is 2040.
Am I getting ... |
The first partition can start at 2040, but it must have the bios_grub flag and that is what your grub install is complaining about.
If you do parted -l /dev/sda you should get something like:
Model: ATA Samsung SSD 840 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number ... | Error installing Grub |
1,580,829,756,000 |
I wanted to try out the new GPT system, and used it to partition my new HDD, with the partitions themselves using ext4. For some reason, about 1-2% of the space in each partition is already shown as used, both in df and gparted. Currently the only content of the partitions is the lost+found folder which occupies all ... |
1-5% is reserved for root and as overhead for the filesystem. It is NORMAL. This is done is to leave root that 1-5% so if the users on the machine fill the disk up, critical system processes and the root user still have a small chunk to play with. As jordanm pointed out, the reserved space is also used to reduce fil... | GPT Partition - Used Space immediately after creating partition [duplicate] |
1,580,829,756,000 |
I'm having difficulties installing an image I've built with Yocto. In the past I've always used u-boot, MBR, and legacy boot. Installing Yocto meant creating boot and rootfs partitions, installing the first stage u-boot boot loader, and copying the files in /boot to the boot partition (a FAT32 partition).
Now I'm tryi... |
The problem ended up being an obscure BIOS setting, which I found looking through the documentation of the machine I'm using. I saw that they noted, in order to make Ubuntu boot on that machine, you had to turn on "PinCntrl Driver GPIO Scheme" in the BIOS. I made that change and my Yocto build started working as wel... | How can I manually install a Yocto image? |
1,698,413,468,000 |
I have a PC with a mechanical interrupt in order to enable different hdds and use different OSs. Windows has bee installed with bios legacy and I am trying to install archlinux-uefi.
At the end of the installation i reboot archlinux and it is all ok, the installation procedure was performed correctly. I shutdown and ... |
UPDATE - now works.
I think is a combination between fstab and bad grub install parameter.
With the following command at installation, now works.
genfstab -t PARTLABEL --> in order to generate fstab based on partitionlabel, and refers to persistent block name (not sure it is necessary)
grub-install --target=x86_64-ef... | archlinux in a different HDD |
1,698,413,468,000 |
I have a CentOS server on VMware that has, among others, a disk of 1.5TB, with a single xfs partition using the whole disk. This disk/partition is running out of space, so I need to increase its size to 2.5TB.
So I increased the size on VMware and tried to delete and add the partition, which failed. Of course, the ori... |
So you have one msdos partition that starts at sector 128.
This is uncommon since the standard would be MiB alignment, starting at sector 2048 (for 512 byte logical sector size).
With GPT, you can still use the start sector 128, that isn't a problem:
# parted /dev/loop0 unit s print free
Model: Loopback device (loopba... | Increase disk size and change from MBR to GPT |
1,698,413,468,000 |
How the tag ID_PART_ENTRY_UUID is computed? Can I get ID_PART_TABLE_UUID from ID_PART_ENTRY_UUID?
I have a disk with GPT partition table and some partitions.
I need to identify which partitions are related to my disk. All partitions in the disk are referenced to partition table in this disk. I can found this partition... |
For GPT ID_PART_TABLE_UUID and ID_PART_ENTRY_UUID are not related, these are just unique UUIDs (or in fact GUIDs converted to UUIDs in libblkid) from GPT header (for ID_PART_TABLE_UUID) and GPT partition entry (for ID_PART_ENTRY_UUID).
UDev has the information simply because it has a basic parent-child relationship kn... | How ID_PART_ENTRY_UUID is computed in GPT? |
1,698,413,468,000 |
I'm using sgdisk in a bash script similar to this:
sgdisk --clear /dev/vda --set-alignment=1 --new 1:34:2047 --typecode 1:EF02 -c 1:"grub" -g /dev/vda
sgdisk --new 2:2048:16779263 --typecode 2:8300 -g /dev/vda
sgdisk --new 3:16779264:20971486 --typecode 3:8200 -g /dev/vda
That works only when the devices are well kn... |
The following will work:
sgdisk --clear /dev/vda --set-alignment=1 --new 1:34:2047 --typecode 1:EF02 -c 1:"grub" -g /dev/vda
sgdisk --new 2:0:-2G --typecode 2:8300 -g /dev/vda
sgdisk --new 3:0:0 --typecode 3:8200 -g /dev/vda
It's much simpler than I thought. sgdisk does all the calculations. The key is the minus sig... | How to determine sizes using sgdisk partitioning in bash script |
1,698,413,468,000 |
I have a UEFI system that I installed Arch Linux on beside Windows, then later removed Windows and made it Linux only, keeping the EFI boot partition of course. After removing all Windows and recovery partitions, my Linux root partition was still identified as /dev/sda5.
lsblk output:
NAME MAJ:MIN RM SIZE RO TYPE ... |
Run fdisk. Carefully note the characteristics of the existing partition (position, size, type, name, UUID if you care). Delete it, then create a new one with the desired number and the same characteristics.
This is a lot of risk for a negligible benefit, so I don't recommend doing it. Partition numbers are pretty arbi... | Changing partition dev path |
1,698,413,468,000 |
I'm running Debian Wheezy on an SSD, and in addition I have two 500GB hard disks in Intel software RAID 0 (fakeraid). Both the SSD and the RAID array have GPT partition layouts. I have set up my fstab to automatically mount one of the partitions on the RAID array, but the root filesystem is on the SSD.
During boot, dm... |
Solution to the original problem
Install kpartx:
sudo aptitude install kpartx
Change these lines in /lib/udev/rules.d/60-kpartx.rules:
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="dmraid-*", \
RUN+="/sbin/kpartx -a -p -part /dev/$name"
to this:
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="DMRAID-*", \
RUN+="/sb... | Automatically run kpartx during boot |
1,698,413,468,000 |
So, I have Windows 7 and Fedora 16 installed on my old HDD. Everything worked well and fine before I've had my new 3TB drive built in, which I initialized as GPT in Windows. Actually I initialized 1,5TB - the rest remains untouched.
After that Fedora won't boot up anymore. Instead it prompts me to maintenance mode, sh... |
I'd try rebuilding the initial ramdisk:
/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update `uname -r`
Failing that, I'd probably give up and update to F17, which should sort out the problem as well.
| Fedora 16 fails to boot after Win7 installed a GPT Drive |
1,698,413,468,000 |
For context, I have a Fedora KDE installation whose partitions take up half my SSD. The other half I left unallocated when I installed Linux.
Although I'm aware that it's dangerous to attempt to extend any of the existing Fedora partitions without booting from a gparted USB environment or similar, I had previously ass... |
Creating, deleting, and modifying partitions in an unallocated space of the same disk containing running Linux partitions is not an issue. The fdisk command, and other partitioning tools, do that all the time.
because most Linux distributions automatically mount any detected filesystems.
Even assuming that this is ... | Dangerous to create partitions in unallocated space on the same disk as the running Linux system? |
1,698,413,468,000 |
Is there any command to list all partition type codes recognizable by currently installed
distribution (In my case Ubuntu 18.04.03 LTS)
I know the following website exists Andries E. Brouwer 1995-2002 - homepages.cwi.nl
yet there should be any command inbuilt in the linux console.
I know that cgdisk shows all partitio... |
Ok finally I found that it's mainly dependent of the filesystem and the volume
identification hex code is/should be present in the filesystem documentation
as seen below for NTFS and EXT4
Conclusion: There is not specific command or tool only for listing partitions hex code besides the function of cgdisk, gdisk, cfdi... | Command to list partition type codes in deb and rpm distributions for MBR and GPT |
1,698,413,468,000 |
My disk partition scheme, as seen by Grub, is as follows:
hd0,gpt1: EFI system
hd0,gpt2: Linux Swap
hd0,gpt3: Linux Filesystem
hd0,gpt4: FreeBSD UFS`
The install process of FreeBSD 11.0-RELEASE went fine, I also tried chrooting and updating the system, just in case. I then booted into Arch Linux and edited /etc/gru... |
While most guides suggest to use chainloader +1 for chainloading, it didn't work for me.
The following configuration did the trick:
insmod ufs2
set root=(hd0,gpt4)
chainloader /boot/loader.efi
| Unable to dual boot FreeBSD alongside Arch Linux with Grub2 |
1,698,413,468,000 |
I just finished installing Arch and my 3TB GPT drive (this is not my boot drive) is not showing in arch. I initialised it as GPT on my windows 7 machine and that machine is still able to read from that drive. Does it have to do with UEFI? My mobo is UEFI and my windows installation is installed as EFI. I wasn't sure h... |
I have no idea why the partition isn't showing up on your Arch desktop (IMO GUIs are strange and unreliable and often have annoying hard-coded assumptions1) but if the partition is visible to the operating system, e.g. with sudo fdisk -l or sudo blkid or sudo lsblk then you can manually mount the partition anywhere yo... | Arch not recognising GPT drive |
1,698,413,468,000 |
I have tried installing Arch Linux and what I ended up with was a partition scheme like this:
/dev/sda:
/dev/sda1 NTFS partition (Windows 7)
/dev/sda2 ext4 (Arch)
/dev/sda3 swap
I don't know why, but for some reason I have been unable to mount the NTFS partition under Linux.
It's worth mentioning that the first... |
This is utterly strange, but I have solved my problem.
As I'm not sure what exactly solved the issue, I'll describe what happened.
First of all, I tried to access the partition from Arch Linux, which
was installed on the same drive. This didn't work;
I deleted the Linux partitions;
I've unplugged the computer from th... | Recover Windows partition in a GPT disk (previously MBR) |
1,698,413,468,000 |
I am trying out Funtoo on a new machine. I've been through the installation process, as described in Funtoo Linux Installation . Specifically, the installation is done from within an existing Linux distro via chroot, though in a new empty SSD. All went fine up to the point of installing the bootloader which fails:
gru... |
I just exited from chroot, unmounted all partitions, rebooted (the other Linux distro), and re-did the same stuff (following http://www.funtoo.org/wiki/Installation_Troubleshooting). It simply worked!
| grub-install --no-floppy /dev/sda fails (Funtoo) |
1,698,413,468,000 |
I intend to create a dualboot persistent usb. I'd like to try creating a USB where I can boot macOS High Sierra and WIndows 10. From what I understand of LVM, I can create 2 VG, 1 APFS and 1 NTFS. This would allow me to boot into Windows10 on a PC and Windows10/macOS on a Mac. I know workarounds involve using 2 USB, o... |
An EFI System Partition is simply a FAT32-formatted partition (with the ESP boot flag set on GPT partition tables). Some UEFI systems will happily load bootloaders from a FAT32 partition on a standard MBR partition. It looks to me like you've created it properly, but lacks formatting. Once formatted, you'll "instal... | How to install rEFInd for DIY multiboot USB |
1,698,413,468,000 |
Assumed we have a MS-Windows/Linux dualboot system that works completely fine:
partitioning scheme: gpt
sda1: Windows
sda2: Linux Root
sda3: Linux Home
Unfortunately this installation is pretty aged, so I would like to perform a Linux reinstallation while maintaining the MS-Windows dualboot.
Question: Does it make ... |
I don't think it's relevant to repartition or recreate your drive's partition table. The GPT is only the table, that points out how the disk is divided and how the partitions are identified. The performance itself is dependent on the partition format, not the partition table (for instance ext4 performs better than ext... | Linux/Windows Dualboot: Does it make sense to repartition a whole drive when reinstalling Linux? |
1,698,413,468,000 |
I have new computer with UEFI. I formated the disc as GPT (not MBR), made few small partions on start (as placeholders for UEFI, for boot, for swap etc ...) then larger partition for system / (and left rest of the disc free for future usage) and installed Gentoo.
But I cannot figure, how to install grub-LEGACY to enab... |
3 possibilities
mbr
Use mbr; waste the disk space over 2 TB
gpt
Use grub2 with gpt.
[Stressing yourself over the scripts etc is not strictly necessary — you can just ignore the suggestion not to edit grub.conf and edit like legacy grub. Just make sure no updates that point to (this) grub automatically run]
hybrid
Us... | How install legacy grub to gpt uefi disk? |
1,698,413,468,000 |
I have a Lenovo Thinkpad W550s that already has Windows 7 on it. I would like to install Fedora 29 Workstation alongside Windows 7, but I have run into some problems.
The hard drive was formatted with MBR (not GPT) and three partitions. Using the fdisk -l command from a Fedora 29 LiveUSB yields the following informati... |
One of two things are the issue:
You created a UEFI only Installer USB
Your booting in UEFI mode and need to boot in MBR/Legacy Mode.
If you can get to the CLI try this :
https://askubuntu.com/questions/162564/how-can-i-tell-if-my-system-was-booted-as-efi-uefi-or-bios
Update:
When I have a USB/ISO that is both UEFI... | Can't install Fedora 29 on Thinkpad W550s due to GPT |
1,698,413,468,000 |
System:
Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm.
Situation:
Without knowing how to create RAID1 properly, I created it badly.
GParted showed a warning that a primary gpt partition table is not there, and that it is using the backup one, I think it showed this twice
GPa... |
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root (su); if you have sudo enabled, you may also do for example sudo -i; see man sudo for all options):
sudo -i
Check what number (mdX) the array has:
cat /... | How to re-create RAID1 really properly |
1,698,413,468,000 |
I have a 2tb hard drive containing gpt and a single 2tb partition with ext4 file system. The partition has one 1.5tb file inside it. I want to change the type of file system of this partition from ext4 to exfat without deleting the 1.5tb file. Can I do that without writing a custom program?
|
There is a tool which some people have successfully used to convert Ext4 partitions to exFAT in place, fstransform. Note that the tool doesn’t officially support conversions to exFAT, and I haven’t tried it — but there are apparently reports of it working (with the --force-untested-file-systems flag).
In any case you ... | Change the file system of a partition without deleting its content |
1,592,331,333,000 |
If I setup a VirtualBox guest with two 30 GB virtual hard disks and follow the following steps, the result will be a fully functional, booting operating system:
Boot Ubuntu 14.04 Server install CD
At the partioner, select 'manual'.
Put a single empty partition on each virtual hard disk.
Select 'Configure software RAI... |
Your 3TB disks need GPT boot rather than MBR, so you will need to allocate a 1MB BIOS boot partition for grub to store its data.
See http://ubuntuforums.org/showthread.php?t=2248346 for the gory details (which I will try to summarise here when I get back to a decent keyboard).
| Ubuntu 14.04 software RAID with LVM install won't boot on bare metal |
1,592,331,333,000 |
I have an ASUS Z170 pro gaming motherboard. Its motherboard uses UEFI, not BIOS. I have two drives:
An SSD with Windows 10 installed.
A blank HDD.
Following the instructions here, I run msinfo32 and get the value of BIOS mode. It says Legacy, which means it boots in BIOS-MBR mode. The wiki has different instructions f... |
Windows was booting in the Legacy mode on a UEFI motherboard, which is incorrect. In order for a Linux bootoader to see Windows, it must be the same type. Reinstalling Windows 10 made it boot in UEFI mode, fixing the bootloader issue. Because Windows 10 is in UEFI mode, it is best to use GPT rather than MBR. None of t... | Arch Linux and Windows 10 dual boot |
1,592,331,333,000 |
I partitioned a MMC card into multiple partitions (in GPT format), and the very first partition is just padding space so that all other partitions are aligned to a optimal boundary.
Problem is, on boot Linux always tries to mount the first partition, which is almost guaranteed to fail, which 1) takes time, 2) if it sh... |
Use the option noauto in /etc/fstab for that mount point to make sure the init process will not mount it at boot.
You might have a line like this in /etc/fstab :
/dev/sda1 /mnt/your_partition ntfs-3g defaults,noauto 0 0
| How to mark a partition as unmountable? |
1,592,331,333,000 |
I have a laptop with SSD which has Windows 10 installed. I booted the laptop from USB flash drive into Ubuntu 14.04.3 and tried to find out the file system on partition 4. According to gdisk it has partition code 0x0700, which means that it is 0x07(0x0700/0x0100) in MBR codes which means HPFS/NTFS/exFAT. This is in ac... |
Turned out, that file-system on /dev/sda4 partition was corrupted and not encrypted. I was able to fix the partition with ntfsfix /dev/sda4. Output of file -s /dev/sda4 and ntfsinfo once the file-system is fixed can be seen below:
root@ubuntu:~# file -s /dev/sda4
/dev/sda4: x86 boot sector
root@ubuntu:~# ntfsinfo -vm ... | Determine Windows file-system on GPT partition |
1,592,331,333,000 |
I have a NTFS hard drive internally attached to my computer and it's causing problems with the other Windows installation on my dual (or triple?) boot machine.
I'm not sure if the partition scheme is GPT or MBR, but how can I create a backup of the partition table using dd and then wipe it from the drive so it isn't r... |
To backup DOS label (MBR) use this:
dd if=/dev/sdX of=mbr bs=512 count=1
To backup GPT label use this:
dummy=$(parted -ms /dev/sdX print | tail -1| cut -b1)
size=$((128 * dummy + 1024))
dd if=/dev/sdX of=gpt bs=1 count=$size
To wipeout the labels use this:
dd if=/dev/zero of=/dev/sdX bs=Y count=Z
partprobe /dev/sdX
... | Backup and then wipe partition table from head of drive |
1,592,331,333,000 |
I've restored backup GPT headers on previously GPT partitioned disks that are member of a Linux software raid (mdraid). This was done because partprobe reported corrupted headers.
Now actually software raid should manage the entire disks but the previously used partition information remains from the time when the ser... |
Version 1.2 metadata is stored 4K from the start of the block device. The data itself is a fair bit in, typically. For example, here is (part of) mdadm -E from a disk in one of my arrays:
/dev/sda3:
Magic : a92b4efc
Version : 1.2
⋮
Data Offset : 262144 sectors
Super Offset : 8 sectors
Unuse... | Data integrity after GPT restore on Mdraid configured disk |
1,592,331,333,000 |
I wanted to upgrade my 1.5TB HDD to a 4TB SSD, none of the internet resources I found correctly matched my situation from beginning to end, and I ended up spending about 20 hours getting it to work, so I'm compiling my findings here for future travelers.
|
Base details: I have an old Dell Inspiron 5720 running Ubuntu 20.04.6. I started with a 1.5TB HDD and bought a 4TB SSD. I discovered that MBR, the partition table my old drive used, did not support partitions larger than ~2TB, so I was going to have to switch to GPT. Apparently this almost inevitably entails switch... | Convert MBR/BIOS to GPT/UEFI (infodump) |
1,592,331,333,000 |
I have a (GPT-partitioned) disk, for example /dev/sda.
/dev/sda8 is a partition on that disk. I used the cfdisk utility to create a GPT table with few partitions in /dev/sda8. I expected these partitions to become available via something like /dev/sda8p1. But Linux did not automatically recognize them.
How do I make L... |
I know of nothing that that will automatically scan a partition as if it were a disk, and indeed it can't even be scanned manually:
partx --add - /dev/sda8
partx: /dev/sda8: error adding partitions 1-2
However, you can use a loop device to map the partition back to a device - and this device can be scanned as if it w... | How to make Linux read partition table in a partition? |
1,592,331,333,000 |
I have built a custom image of Armbian with a partition size of 3.1 GB, and I am now finished working with it. It is currently written to a bootable 64 GB SD card which is using a GUID partition table (GPT).
My problem is, is that when I want to make an image of the card using Ubuntu, I get an image file 63 GB in size... |
truncate is a good tool. You need to shrink the image, so it contains every partition defined in the partition table. In other words, if the end sector of the partition closest to the end is N (note it doesn't have to be the partition with the highest number), you need N+1 sectors of the image (+1 because numbering st... | Problem creating a disk image of an SD card |
1,592,331,333,000 |
From UEFI spec 2.8, GPT partition entry array definition (5.3.3), I understand that Unique Partition GUID is to "uniquely identify every partition that will ever be created". And the language seemingly implies there can be a pool of GUIDs or some default GUID generator. Then where does this pool/generator usually resi... |
The tool that creates the new partition also generates the GUID for it. fdisk uses the uuid_generate_random function from libuuid for that.
If you are interested in details, RFC 4122 describes UUIDs in more details and also includes description of algorithms to create them. (UUID and GUID are more or less synonyms, th... | How is the value of the "unique partition GUID" is generated? |
1,592,331,333,000 |
System: Linux Mint 20 x64 cinnamon booted on mbr formatted disk.
I inserted a new hdd containing a gpt and a ntfs partition (next to a small MSR partition, which doesn't matter here I guess). GParted detects the hdd but the mount option is greyed out. Why is that? And what can I do to mount this partition?
|
Like suggested in the comments the problem was indeed the hybernation flag. The ntfs-3g driver cannot safely mount the ntfs disk as Windows is in a hybernation state. This article explains it perfectly: all-explaining article
some possible solutions:
if you have access to Windows: boot into windows and do a normal sh... | Can I mount a gpt disk with ntfs partition on an mbr booted linux system |
1,286,911,424,000 |
I'm looking for an easy way (a command or series of commands, probably involving find) to find duplicate files in two directories, and replace the files in one directory with hardlinks of the files in the other directory.
Here's the situation: This is a file server which multiple people store audio files on, each user... |
There is a perl script at http://cpansearch.perl.org/src/ANDK/Perl-Repository-APC-2.002/eg/trimtrees.pl which does exactly what you want:
Traverse all directories named on the
command line, compute MD5 checksums
and find files with identical MD5. IF
they are equal, do a real comparison
if they are really equa... | Is there an easy way to replace duplicate files with hardlinks? |
1,286,911,424,000 |
I read in text books that Unix/Linux doesn't allow hard links to directories but does allow soft links. Is it because, when we have cycles and if we create hard links, and after some time we delete the original file, it will point to some garbage value?
If cycles were the sole reason behind not allowing hard links, th... |
This is just a bad idea, as there is no way to tell the difference between a hard link and an original name.
Allowing hard links to directories would break the directed acyclic graph structure of the filesystem, possibly creating directory loops and dangling directory subtrees, which would make fsck and any other file... | Why are hard links to directories not allowed in UNIX/Linux? |
1,286,911,424,000 |
I know what hard links are, but why would I use them? What is the utility of a hard link?
|
The main advantage of hard links is that, compared to soft links, there is no size or speed penalty. Soft links are an extra layer of indirection on top of normal file access; the kernel has to dereference the link when you open the file, and this takes a small amount of time. The link also takes a small amount of spa... | Why do hard links exist? |
1,286,911,424,000 |
I'm creating a shell script that would take a filename/path to a file and determine if the file is a symbolic link or a hard link.
The only thing is, I don't know how to see if they are a hard link. I created 2 files, one a hard link and one a symbolic link, to use as a test file. But how would I determine if a file ... |
Jim's answer explains how to test for a symlink: by using test's -L test.
But testing for a "hard link" is, well, strictly speaking not what you want. Hard links work because of how Unix handles files: each file is represented by a single inode. Then a single inode has zero or more names or directory entries or, techn... | Determining if a file is a hard link or symbolic link? |
1,286,911,424,000 |
If you do rm myFile where myFile is a hard link, what happens?
|
In Unix all normal files are Hardlinks. Hardlinks in a Unix (and most (all?)) filesystems are references to what's called an inode. The inode has a reference counter, when you have one "link" to the file (which is the normal modus operandi) the counter is 1. When you create a second, third, fourth, etc link, the count... | What happens when you delete a hard link? |
1,286,911,424,000 |
How can we find all hard links to a given file?
I.e., find all other hard links to the same file, given a hard link?
Does filesystem keep track of the hard links to a file?
The inode of a file only stores the number of hard links to the file, but not the hard links, right?
|
If the given file is called /path/to/file and you want to find all hard links to it that exist under the current directory, then use:
find . -samefile /path/to/file
The above was tested on GNU find. Although -samefile is not POSIX, it is also supported by Mac OSX find and FreeBSD find.
Documentation
From GNU man fi... | How to find all hard links to a given file? [duplicate] |
1,286,911,424,000 |
When would you use one over the other?
|
The different semantics between hard and soft links make them suitable for different things.
Hard links:
indistinguishable from other directory entries, because every directory entry is hard link
"original" can be moved or deleted without breaking other hard links to the same inode
only possible within the same files... | What is the difference between symbolic and hard links? |
1,286,911,424,000 |
How to move directories that have files in common from one to another partition ?
Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks.
How to move such directories to another partition , let it be /mnt/Y with preserving those hardlinks.
For better illustration what do I mean ... |
First answer: The GNU Way
GNU cp -a copies recursively preserving as much structure and metadata as possible. Hard links between files in the source directory are included in that. To select hard link preservation specifically without all the other features of -a, use --preserve=links.
mkdir src
cd src
mkdir -p a/{b,c... | How to copy directories with preserving hardlinks? |
1,286,911,424,000 |
I've seen many explanations for why the link count for an empty directory in Unix based OSes is 2 instead of 1. They all say that it's because of the '.' directory, which every directory has pointing back to itself. I understand why having some concept of '.' is useful for specifying relative paths, but what is gained... |
An interesting question, indeed. At first glance I see the following advantages:
First of all you state that interpreting "." as the current directory may be done by the Shell or by system calls. But having the dot-entry in the directory actually removes this necessity and forces consistency at even a lower level.
But... | Why is '.' a hard link in Unix? |
1,286,911,424,000 |
In what situations would one want to use a hard-link rather than a soft-link? I personally have never run across a situation where I'd want to use a hard-link over a soft-link, and the only use-case I've come across when searching the web is deduplicating identical files.
|
Aside from the backup usage mentioned in another comment, which I believe also includes the snapshots on a BTRFS volume, a use-case for hard-links over soft-links is a tag-sorted collection of files. (Not necessarily the best method to create a collection, a database-driven method is potentially better, but for a sim... | Use cases for hardlinks? [closed] |
1,286,911,424,000 |
A hard link is defined as a pointer to an inode. A soft link, also known as a symbolic link, is defined as an independent file pointing to another link without the restrictions of hard links.
What is the difference between a file and a hard link? A hard link points to an inode, so what is a file? The inode entry itsel... |
The very short answer is:
a file is an anonymous blob of data
a hardlink is a name for a file
a symbolic link is a special file whose content is a pathname
Unix files and directories work exactly like files and directories in the real world (and not like folders in the real world); Unix filesystems are (conceptually... | What is the difference between a hard link and a file? |
1,286,911,424,000 |
I'm running an application that writes to log.txt. The app was updated to a new version, making the supported plugins no longer compatible. It forces an enormous amount of errors into log.txt and does not seem to support writing to a different log file.
How can I write them to a different log?
I've considered replacin... |
# cp -a /dev/null log.txt
This copies your null device with the right major and minor dev numbers to log.txt so you have another null.
Devices are not known by name at all in the kernel but rather by their major and minor numbers. Since I don't know what OS you have I found it convenient to just copy the numbers from... | Replace file with hard link to /dev/null |
1,286,911,424,000 |
For example, I have a file myold_file. Then I use ln to create a hard link as mylink:
ln myold_file mylink
Then, even by using ls -a, I cannot tell which is the old one.
Is there anyway to tell?
|
You can't, because they are literally the same file, only reached by different paths. The first one has no special status.
| How to tell which file is original if hard link is created |
1,286,911,424,000 |
Two setuid programs, /usr/bin/bar and /usr/bin/baz, share a single configuration file foo. The configuration file's mode is 0640, for it holds sensitive information. The one program runs as bar:bar (that is, as user bar, group bar); the other as baz:baz. Changing users is not an option, and even changing groups would ... |
You can use ACLs so the file can be read by people in both groups.
chgrp bar file
chmod 640 file
setfacl -m g:baz:r-- file
Now both bar and baz groups can read the file.
For example, here's a file owned by bin:bin with mode 640.
$ ls -l foo
-rw-r-----+ 1 bin bin 5 Aug 17 12:19 foo
The + means there's an ACL set, so ... | One file wants to belong to two users. How? Hard linking fails |
1,286,911,424,000 |
I am reading this intro to the command line by Mark Bates.
In the first chapter, he mentions that hard links cannot span file systems.
An important thing to note about hard links is that they only work on the current file system. You can not create a hard link to a file on a different file system. To do that you need... |
Hopefully I can answer this in a way that makes sense for you.
A file system in Linux, is generally made up of a partition that is formatted in one of various ways (gotta love choice!) that you store your files on. Be that your system files, or your personal files... they are all stored on a file system. This part you... | Why are hard links only valid within the same filesystem? |
1,286,911,424,000 |
This answer reveals that one can copy all files - including hidden ones - from directory src into directory dest like so:
mkdir dest
cp -r src/. dest
There is no explanation in the answer or its comments as to why this actually works, and nobody seems to find documentation on this either.
I tried out a few things. Fi... |
The behaviour is a logical result of the documented algorithm for cp -R. See POSIX, step 2f:
The files in the directory source_file shall be copied to the directory dest_file, taking the four steps (1 to 4) listed here with the files as source_files.
. and .. are directories, respectively the current directory, and ... | cp behaves weirdly when . (dot) or .. (dot dot) are the source directory |
1,286,911,424,000 |
On Linux, when you a create folder, it automatically creates two hard links to the corresponding inode.
One which is the folder you asked to create, the other being the . special folder this folder.
Example:
$ mkdir folder
$ ls -li
total 0
124596048 drwxr-xr-x 2 fantattitude staff 68 18 oct 16:52 folder
$ ls -l... |
It is technically possible to delete ., at least on EXT4 filesystems. If you create a filesystem image in test.img, mount it and create a test folder, then unmount it again, you can edit it using debugfs:
debugfs -w test.img
cd test
unlink .
debugfs doesn't complain and dutifully deletes the . directory entry in the ... | How to unlink (remove) the special hardlink "." created for a folder? |
1,286,911,424,000 |
Is there a limit of number of hardlinks for one file? Is it specified anywhere? What are safe limits for Linux? And what for other POSIX systems?
|
Posix requires that the operating system understand the concept of hard links but not that hard links can actually be used in any particular circumstance. You can find out how many hard links are permitted at a particular location (this can vary by filesystem type) by calling pathconf(filename, _PC_LINK_MAX). The mini... | Is there a limit of hardlinks for one file? |
1,286,911,424,000 |
Which permissions affect hard link creation? Does file ownership itself matter?
Suppose user alice wants to create a hard link to the file target.txt in a directory target-dir.
Which permissions does alice need on both target.txt and target-dir?
If target.txt is owned by user bill and target-dir is owned by user cha... |
To create the hard link, alice will need write+execute permissions on target-dir on all cases. The permissions needed on target.txt will vary:
If fs.protected_hardlinks = 1 then alice needs either ownership of target.txt or at least read+write permissions on it.
If fs.protected_hardlinks = 0 then any set of permissio... | Hard link creation - Permissions? |
1,286,911,424,000 |
In the manual page of tar command, an option for following hard links is listed.
-h, --dereference
follow symlinks; archive and dump the files they point to
--hard-dereference
follow hard links; archive and dump the files they refer to
How does tar know that a file is a hard link? How does it follow it?
... |
By default, if you tell tar to archive a file with hard links, and more than one such link is included among the files to be archived, it archives the file only once, and records the second (and any additional names) as hard links. This means that when you extract that archive, the hard links will be restored.
If you... | Dereferencing hard links |
1,286,911,424,000 |
Thanks to some good Q&A around here and this page, I now understand links. I see hard links refer the same inode by a different name, and copies are different "nodes, with different names. Plus soft links have the original file name and path as their inode, so if the file is moved, the link breaks.
So, I tested what I... |
A file is an inode with meta data among which a list of pointers to where to find the data.
In order to be able to access a file, you have to link it to a directory (think of directories as phone directories, not folders), that is add one or more entries to one of more directories to associate a name with that file.
A... | Why do hard links seem to take the same space as the originals? |
1,286,911,424,000 |
I use rsnapshot for backups, which generates a series of folders containing files of the same name. Some of the files are hard linked, while others are separate. For instance, hourly.1/file1 and hourly.2/file1 might be hard linked to the same file, while hourly.1/file2 and hourly.2/file2 are entirely separate files.
I... |
Total size in bytes of all files in hourly.2 which have only one link:
$ find ./hourly.2 -type f -links 1 -printf "%s\n" | awk '{s=s+$1} END {print s}'
From find man-page:
-links n
File has n links.
To get the sum in kilobytes instead of bytes, use -printf "%k\n"
To list files with different link counts... | How to get folder size ignoring hard links? |
1,286,911,424,000 |
I understand the notion of hardlinks very well, and have read the man pages for basic tools like cp --- and even the recent POSIX specs --- a number of times. Still I was surprised to observe the following behavior:
$ echo john > john
$ cp -l john paul
$ echo george > george
At this point john and paul will have the ... |
First, why is it done this way? One reason is historical: that's how it was done in Unix First Edition.
Files are taken in pairs; the first is opened for reading,the second created mode 17. Then the first is copied into the second.
“Created” refers to the creat system call (the one that's famously missing an e), whi... | Surprised by behavior of cp with hardlinks |
1,286,911,424,000 |
This is a bit of a theoretical question, but it's important to use proper names for things.
In UNIX/Linux file systems, .. points to the parent directory.
However, we know that hard links cannot point to directories, because that has the potential to break the acyclic graph structure of the filesystem and cause comman... |
It depends on the filesystem. Most filesystems follow the traditional Unix design, where . and .. are hard links, i.e. they're actual directory entries in the filesystem. The hard link count of a directory is 2 + n where n is the number of subdirectories: that's the entry in the directory's parent, the directory's own... | Is '..' really a hard link? |
1,286,911,424,000 |
When you upgrade or reinstall a package with dpkg (and ultimately anything that uses it, like apt-get etc) it backs up the existing files by creating a hard link to the file before replacing it. That way if the unpack fails it can easily put back the existing files. That's great, since it protects the operating syst... |
The behaviour you're seeing is implemented in archives.c in the dpkg source, line 1030 (for version 1.18.1):
debug(dbg_eachfiledetail, "tarobject nondirectory, 'link' backup");
if (link(fnamevb.buf,fnametmpvb.buf))
ohshite(_("unable to make backup link of '%.255s' before installing new version"),
ti->name)... | dpkg replacing files on a FAT filesystem |
1,286,911,424,000 |
I was wondering if there was a way to register this, but since most modern search engines don't work well with phrases over about 5 words in length, I need some help on this one.
I was wondering this because I'm making a bash script that has to register files as certain types and make decisions accordingly. This t... |
In Unix-style systems, the data structure which represents filesystem objects (in other words, the data about a file), is stored in what's called an "inode".
A file name is just a link to this inode, and is referred to as a "hard link". There is no difference between the first name a file is given and any subsequent l... | Do hard links count as normal files? |
1,286,911,424,000 |
I am keeping my dotfiles under version control and the script deploying them creates hard links. I also use etckeeper to put my /etc under version control. Recently I have gotten warnings like this:
warning: hard-linked files could cause problems with bzr
A simple copy (cp filename.ext filename.ext) will not work:
cp... |
cp -p filename filename.tmp
mv -f filename.tmp filename
Making it scriptable:
dir=$(dirname -- "$filename")
tmp=$(TMPDIR=$dir mktemp)
cp -p -- "$filename" "$tmp"
mv -f -- "$tmp" "$filename"
Doing the copy first, then moving it into place, has the advantage that the file atomically changes from being a hard link to b... | Breaking a hard-link in-place? |
1,286,911,424,000 |
From the man pages:
ln - make links between files
and
link - call the link function to create a link to a file
These seem to do the same thing however ln takes a lot of options as well.
Is link just a very basic ln? Is there any reason to use link over ln?
|
link used solely for hard links, calls the link() system function and doesn't perform error checking when attempting to create the link
ln has error checking and can create hard and soft links
| What is the difference between the link and ln commands? |
1,286,911,424,000 |
I am implementing a backup scheme using rsync and hardlinks. I know I can use link-dest with rsync to do the hardlinks, but I saw mention of using "cp -l" before "link-dest" was implemented in rsync. Another method of hardlinking I know of is "ln".
So my question is, out of curiosity: is there a difference in making h... |
The results of both has to be the same, in that a hard link is created to the original file.
The difference is in the intended usage and therefore the options available to each command. For example, cp can use recursion whereas ln cannot:
cp -lr <src> <target>
will create hard links in <target> to all files in <src>.... | Is there a difference between hardlinking with cp -l or ln? |
1,286,911,424,000 |
When I stat a directory I get a listing that tell me there are 5 links to the directory.
stat dir
My question is how do I get information (names and locations) to all these 5 links?
|
You just need ls (or find).
When you create a directory, its link count starts at 2:
One for the directory itself
One for the . link inside itself
The other thing that increases the directory's link count is its subdirectories: they all have a .. entry linking back to their parent, adding one to its link count.
You ... | How to find all the links to a directory |
1,286,911,424,000 |
When I wanted to create a hard link in my /home directory in root mode, Linux showed the following error message:
ln: failed to create hard link ‘my_sdb’ => ‘/dev/sda1’: Invalid cross-device link
The above error message is shown below:
# cd /home/user/
# ln /dev/sda1 my_sdb
But I could only create a hard link in the... |
But I could only create a hard link in the /dev directory and it was not possible in other directories.
As shown by the error message, it is not possible to create a hard link across different filesystems; you can create only soft (symbolic) links.
For instance, if your /home is in a different partition than your ro... | Why I can't create a hard link from device file in other than /dev directory? |
1,286,911,424,000 |
I am trying to take snapshots of a massive folder regularly.
I have read here: http://www.mikerubel.org/computers/rsync_snapshots/#Incremental
that cp -al takes a snapshot of a folder by simply copying the hard links.
That is all great, but the problem is that in this snapshot, if I change a file, it changes in all sn... |
That's how hardlinks work. But, there are ways around it:
A couple of options come to mind:
Use a filesystem with support for copy-on-write files, like btrfs. Of course, were you using btrfs, you'd just use its native snapshots... If your filesystem supports it, you can use cp --reflink=always. Unfortunately, ext4 do... | `cp -al` snapshot whose hard links get directed to a new file when edited |
1,286,911,424,000 |
I have some complex read-only data in my file system. It contains thousands of snapshots of certain revisions of a svn repository, and the output of regression tests. Identical files between snapshots are already de-duplicated using hard links. This way, the storage capacity doesn't need to be large, but it still cons... |
If it's abot fsck slowness, did you try ext4? They added a few features to it that make fsck really quick by not looking at unused inodes:
Fsck is a very slow operation, especially the first step: checking all the inodes in the file system. In Ext4, at the end of each group's inode table will be stored a list of unus... | filesystem for archiving |
1,286,911,424,000 |
Let's say I have two hard links pointing at the same picture.
/photography/picture_1.jpg
/best_pictures/picture_1.jpg
What happens if I edit /photography/picture_1.jpg? Is the hard link broken and did I end up with 2 different files? Does it keep the link and therefore edit the "second" file, accessed by the second p... |
A hard link is simply an alternative name for the same inode (file). Editing the file found at either of those paths will change the picture that both paths point to.
A soft/symbolic link is different: it's a pointer to the original file and can be broken. A hard link is not a pointer to the file, it is the same file ... | Editing a file with several hard links |
1,286,911,424,000 |
From the manpage for ln:
-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will
probably fail due to system restrictions, even for the superuser)
Are there any filesystem drivers that actually allow this, or is the only option mount --bind <src> <dest>?
Or is this kind of behavio... |
First a note: the ln command does not have options like -d, -F, --directory, this is a non-portable GNUism.
The feature you are looking for, is implemented by the link(1)command.
Back to your original question:
On a typical UNIX system the decision, whether hard links on directories are possible, is made in the filesy... | Are there any filesystems for which `ln -d` succeeds? |
1,286,911,424,000 |
Is there a way to tell cp to --link (i.e. create hard links), but fall back in the case where I am attempting inter-device hardlinks? Inter-device links aren't possible and would cause cp to fail.
The reason I am asking is because I would like to use this in a GNUmakefile and would prefer a readable command line over ... |
cp doesn't have this option. You could write a wrapper script, but it's pretty simple.
ln -f $^ $@ 2>/dev/null || cp -f $^ $@
GNU Coreutils 7.5 introduced the --reflink option. If you pass --reflink=auto and the underlying filesystem supports copy-on-write (e.g. Btrfs or ZFS) and the copy happens to be on the same de... | Is there a way to express: `--link` or fall back to ordinary copy in cp (from GNU coreutils)? |
1,286,911,424,000 |
I've got a directory tree created by rsnapshot, which contains multiple snapshots of the same directory structure with all identical files replaced by hardlinks.
I would like to delete all those hardlink duplicates and keep only a single copy of every file (so I can later move all files into a sorted archive without h... |
In the end it wasn't too hard to do this manually, based on Stéphane's and xenoid's hints and some prior experience with find.
I had to adapt a few commands to work with FreeBSD's non-GNU tools — GNU find has the -printf option that could have replaced the -exec stat, but FreeBSD's find doesn't have that.
# create a l... | How to delete all duplicate hardlinks to a file? |
1,286,911,424,000 |
I understand the technical difference between symlinks and hardlinks, this is a question about their use in practice, particularly I'm curious to know why both are used in seemingly similar conditions: the /bin directory.
Here's a fragment its listing on my system:
~$ ls -lai /bin
total 10508
32770 drwxr-xr-x 2 root ... |
Why use hardlinks vs. Symbolic links
There are primarily 3 advantages of using hardlinks over symbolic links in this scenario.
Hard links
With a hard link, the link points to the inode directly.
Hard links are like having multiple copies of the executable but only using the disk space of one.
You can rename either b... | Why is there a mix of symlinks and hardlinks in /bin? |
1,286,911,424,000 |
I have a script that goes like this
ln /myfile /dev/${uniquename}/myfile
I want to remove the link of /dev/somename/myfile to decrease the link count.
How do I do this?
|
TL;DR... just delete the file name you don't want (with rm).
If you create a hard link (which is what your command above is doing), you have two names pointing to the same area of storage. You can delete either name without affecting the other name or the storage - it's only when the last name is removed that the area... | Properly unlinking hard links |
1,286,911,424,000 |
I'm getting a permissions error in CentOS 7 when I try to create a hard link. With the same permissions set in CentOS 6 I do not get the error. The issue centers on group permissions. I'm not sure which OS version is right and which is wrong.
Let me illustrate what's happening. In my current working directory, I have... |
I spun up some fresh CentOS 6 and 7 vm's and was able to recreate the exact behavior you showed. After doing some digging, it turns out that this is actually a change in the kernel regarding default behavior with respect to hard and soft links for the sake of security. The following pages pointed me in the right direc... | Hard link permissions behavior different between CentOS 6 and CentOS 7 |
1,286,911,424,000 |
Note: Question although says vice versa but it really does not have any meaning since both of them point to the same inode and its not possible to say which is head and which is tail.
Say I have a file hlh.txt
[root@FREL ~]# fallocate -l 100 hlh.txt
Now if I see the change time for hlh.txt
[root@FREL ~]# stat hlh.txt... |
This is a requirement on the unlink() library function by POSIX:
Upon successful completion, unlink() shall mark for update the last data modification and last file status change timestamps of the parent directory. Also, if the file's link count is not 0, the last file status change timestamp of the file shall be mar... | Deleting a hard link's tail file changes the change time of the head or vice versa. Why? |
1,286,911,424,000 |
I'm trying to understand what cp --preserve=links does when used by itself.
From my tests it seems that it copies a normal file normally and dereferences symlinks, but it seems like it just has the same effect as cp -L when used on a single file.
Is that true or is there something I'm missing?
|
The --preserve=links option does not refer to symbolic links, but to hard links. It asks cp to preserve any existing hard link between two or more files that are being copied.
$ date > file1
$ ln file1 file2
$ ls -1i file1 file2
6034008 file1
6034008 file2
You can see that the two original files are hard-linked and t... | Info on cp --preserve=links |
1,286,221,328,000 |
When displaying directories using ls -l, their number of links (the second field in the output) is at least two: one for the dir name and one for .
$ mkdir foo
$ ls -l
total 2
drwxr-xr-x 2 user wheel 512 4 oct 14:02 foo
Is it safe to always assume that the number of links above 2 corresponds to the number of su... |
It is usually true on unix systems that the number of links to a directory is the number of subdirectories plus 2. However there are cases where this is not true:
Some unices allow hard links to directories. Then there will be more than 2 links that do not correspond to subdirectories.
There are filesystems where dir... | Can I determine the number of sub-directories in a directory using `ls -l`? |
1,286,221,328,000 |
Suppose User A and User B have disk quotas of 1 GB.
Also suppose User B creates a 900 MB file with permission 0666.
This allows User A to access that file temporarily (for some project, etc.).
Notice this allows User A to write to the file as well.
If User A creates a hard link to that file, and User B then deletes t... |
This is one of the ugly corner cases of the Unix permission model. Granting write access to a file permits hard-linking it. If user A has write permission to the directory containing the file, they can move it to a directory where user B has no access. User B then can't access the file anymore, but it still counts aga... | Hard Linking Other Users' Files |
1,286,221,328,000 |
I got a tarball (let's say t.tar.gz) that contains the following files
./a/a.txt
./b/b.txt
where ./b/b.txt is a hard link to ./a/a.txt.
I want to unpack the tarball on a network file system (AFS) that only supports hard links in the same directory (see here).
Therefore, just unpacking it via tar -xzf t.tar.gz raises... |
Mount the archive as a directory, for example with AVFS, then use your favorite file copying tool.
mountavfs
cp -a --no-preserve=links ~/.avfs/path/to/t.tar.gz\# target-directory/
or
mountavfs
rsync -a ~/.avfs/path/to/t.tar.gz\#/ target-directory/
| unpacking tarball with hard links on a file system that doesn't support hard links |
1,286,221,328,000 |
Softlinks are easily traceable to the original file with readlink etc... but I am having a hard time tracing hardlinks to the original file.
$ ll -i /usr/bin/bash /bin/bash
1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /bin/bash*
1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /usr/bin/bash*
... |
First, there is no original file in the case of hard links; all hard links are equal.
However, hard links aren’t involved here, as indicated by the link count of 1 in ls -l’s output:
$ ll -i /usr/bin/bash /bin/bash
1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /bin/bash*
1310813 -rwxr-xr-x 1 root root 11834... | How to effectively trace hardlink in Linux? |
1,286,221,328,000 |
$ sudo su
# dd if=/dev/zero of=./myext.img bs=1024 count=100
.
.
.
# modprobe loop
# losetup --find --show myext.img
/dev/loop0
# mkfs -t myext /dev/loop0
.
.
.
# mkdir mnt
# mount /dev/loop0 ./mnt
# cd mnt
# ls -al
total 17
drwxr-xr-x 3 root root 1024 Jul 21 02:22 .
drwxr-xr-x 11 shisui shisui 4096 Jul 21 02:22 .... |
You don’t see mnt in the ls -al output because you’re inside mnt; it is represented by .
There’s another hard link to ., lost+found/..; this explains the count of 3 links to the directory:
. which points to the directory itself;
.. which also points to the directory, because it’s the root directory in the file system... | Why does this new directory have a link count of 3? |
1,286,221,328,000 |
Having a (single, no batch filesystem processing needed) symlink, what a command line to use to turn it into a hard link to the same file?
|
ln -f "$(readlink <symlink>)" <symlink>
| How to replace a symbolic link with an equivalent hard link? |
1,286,221,328,000 |
I've found that I need to use hard links with a particular program (Ableton Live) that is unable to see aliases/symlinks, which is of course how I have all my working files organized. But making hard links is creating what appears to be duplicates of the original file.
Do they actually take up as much space as the or... |
The second thing you said is exactly correct. The file contents only exist once on disk. A hard link is an extra reference, which costs very little space - the size of a directory entry, which is the length of the filename plus a few bytes.
I don't know if this applies to OSX, but in the version of GNU coreutils I hav... | Do hard links really take up so much disk space? |
1,286,221,328,000 |
Can anyone help me to understand the logic behind the link value being "2" for the first time when we create any folders/ directory in linux.
I searched a lot , but couldn't get satisfactory logic
|
The fundamental design of the Unix filesystem goes back to the early days. It is described in the paper The UNIX Time-Sharing System by Dennis M. Ritchie and Ken Thompson.
The designers wanted to be able to refer to the current directory, and to have a way to go from a directory to its parent directory. Rather than in... | Link value is 2 by default for folders |
1,286,221,328,000 |
I know we can do that for files. What about directories?
It seems that cpanel uses that a lot.
|
Most filesystem do not support hard links on directories. However, you can symlink directories.
You can bind mount a directory in Linux, which functions similar to a hard link from a user's perspective. Here is an example:
mount --bind /usr /home/user/foo
This is commonly used for chroot environments, since a symlin... | Can we use symbolic link and hard link for directories? |
1,286,221,328,000 |
The reason why I am asking is because I'm using iwatch (not to confuse with a gadget device) to watch for filesystem events (in my case - file creation/renaming).
What I cannot explain is this log:
/path/to/file.ext.filepart 0 IN_MODIFY
/path/to/file.ext.filepart 0 IN_MODIFY
/path/to/file.ext.filepart 0 IN_MODIFY
/... |
$ inotifywait -m /tmp
Setting up watches.
Watches established.
/tmp/ CREATE file.ext.filepart
/tmp/ OPEN file.ext.filepart
/tmp/ MODIFY file.ext.filepart
/tmp/ CLOSE_WRITE,CLOSE file.ext.filepart
/tmp/ CREATE file.ext
/tmp/ DELETE file.ext.filepart
Transcript from running
$ echo hello >/tmp/file.ext.filepart
$ ln /tm... | Is it possible to create a non-empty file without write_close and rename event? |
1,286,221,328,000 |
A question for ls command.
root@cqcloud script]# ls /var/www/html -la
total 36
drwxr-xr-x 9 root root 4096 Aug 31 01:12 .
drwxr-xr-x 7 root root 4096 Aug 31 01:10 ..
drwxr-xr-x 2 root root 4096 Aug 26 04:07 cmd
drwxr-xr-x 5 root root 4096 Jul 3 10:07 cn.fnmili.com
drwxr-xr-x 7 root root 4096 Aug 30 11:42 inter... |
The link count for a directory is the number of names that directory has (this works just as for regular files).
Your cmd directory has two names:
cmd in its parent directory.
. in the directory itself.
The /var/www/html directory has nine names:
html in its parent directory.
. in itself.
.. in each of its (seven) ... | The number of links for a folder doesn't reflect the real status? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.