Can't rsync : write failed - No space left on device (28)

7,807

Solution 1

Your external disk has only 47G left. Your /home partition weighs 91G.

Today's Linux distributions offer encryption and it is not uncommon that there exist a hidden directory /home/.ecryptfs that actually holds all the files. Your excluding rule /home/* would not exclude that directory.

If you want to also exclude hidden directories, exclude the whole /home, not /home/*. BTW, think about the --one-file-system option, I find it error-prone to save / while excluding a long list of directories.

Solution 2

Sometimes when I want to access only the root file-system, I use the trick:

mkdir /bind
mount -o bind / /bind
cd /bind

Now, I can see the root file-system without any sub-mounts. If I do a:

cp -a . /some/other/volume

or

rsync -tral . /some/other/volume/

Then it will not pick up any volumes mounted on my root file system.

Share:
7,807

Related videos on Youtube

SessionR
Author by

SessionR

Updated on September 18, 2022

Comments

  • SessionR
    SessionR over 1 year

    I've been trying to save my "/" without success for the past hours :(

    I'm on a testing branch of Debian, I'd like to save my system every time before updating. The backup would go on the second drive which is a bootable Win7.

    sudo rsync -aAXv --inplace --info=progress2 --no-whole-file --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/*} / "/media/sessionR/Disque Dur 1/System_save_sauvegarde_25.03.2017/" > save.txt 
    

    The same command below (not sure about best readability)

    sudo rsync -aAXv --inplace --info=progress2 --no-whole-file --exclude={"/dev/\*","/proc/\*","/sys/\*","/tmp/\*","/run/\*","/mnt/\*","/media/\*","/lost+found","/home/\*} / "/media/sessionR/Disque Dur 1/System_save_sauvegarde_25.03.2017/" > save.txt 
    
    • Source "/" is on my internal laptop sata hard drive.

    • Destination "/media/sessionR/Disque Dur 1/System_save_sauvegarde_25.03.2017/" is the mount point for "/dev/sdb2" which is a second internal sata hard drive replacing the DVD drive.

    After some files get copied, tons of files come up with error: No space left on device (28) :

    rsync: recv_generator: mkdir "/media/sessionR/Disque Dur 1/System_save_sauvegarde_25.03.2017/var/tmp" failed: No space left on device (28)
    *** Skipping any contents from this failed directory ***
    

    And the end result below is like 2Gb instead of the ±11Gb announced by the dry run:

    sent 2,554,663,982 bytes  received 1,188,942 bytes  17,446,095.04 bytes/sec
    total size is 11,825,525,653  speedup is 4.63
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
    

    I don't get it; I have ample space:

    df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            1.9G     0  1.9G   0% /dev
    tmpfs           376M   21M  356M   6% /run
    /dev/sda1        18G   12G  5.3G  69% /
    tmpfs           1.9G     0  1.9G   0% /dev/shm
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/sda5       2.7G 1008M  1.6G  39% /var
    /dev/sda8       120G   91G   24G  80% /home
    /dev/sda7       360M   32M  306M  10% /tmp
    tmpfs           376M   24K  376M   1% /run/user/1000
    /dev/sdb2       287G  240G   47G  84% /media/sessionR/Disque Dur 1
    

    Could it be something about the filesystem ? (Hidden NTFS WinRE+ HPFS/NTFS/exFAT)

    findmnt /dev/sdb2

    TARGET SOURCE FSTYPE OPTIONS

    /media/sessionR/Disque Dur 1 /dev/sdb2 fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permis‌​sions,allow_other,bl‌​ksize=4096

    sudo fdisk -l
    [sudo] password for sessionR: 
    Disk /dev/sda: 149.1 GiB, 160041885696 bytes, 312581808 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x5def152b
    
    Device     Boot    Start       End   Sectors   Size Id Type
    /dev/sda1  *        2048  38057983  38055936  18.2G 83 Linux
    /dev/sda2       38057984 312581807 274523824 130.9G  5 Extended
    /dev/sda5       38060032  43917311   5857280   2.8G 83 Linux
    /dev/sda6       43919360  56475647  12556288     6G 82 Linux swap / Solaris
    /dev/sda7       56477696  57255935    778240   380M 83 Linux
    /dev/sda8       57257984 312580095 255322112 121.8G 83 Linux
    
    
    Disk /dev/sdb: 298.1 GiB, 320072933376 bytes, 625142448 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0xf571c4f5
    
    Device     Boot    Start       End   Sectors   Size Id Type
    /dev/sdb1             63  25173854  25173792    12G 27 Hidden NTFS WinRE
    /dev/sdb2  *    25174016 625139703 599965688 286.1G  7 HPFS/NTFS/exFAT
    

    Apparently it's not inodes:

    df -ih
    Filesystem     Inodes IUsed IFree IUse% Mounted on
    udev             467K   471  466K    1% /dev
    tmpfs            470K   772  469K    1% /run
    /dev/sda1        1.2M  441K  712K   39% /
    tmpfs            470K     1  470K    1% /dev/shm
    tmpfs            470K     6  470K    1% /run/lock
    tmpfs            470K    15  470K    1% /sys/fs/cgroup
    /dev/sda5        179K   17K  162K   10% /var
    /dev/sda7         96K    26   96K    1% /tmp
    /dev/sda8        7.7M   50K  7.6M    1% /home
    tmpfs            470K    21  470K    1% /run/user/1000
    /dev/sdb2         47M  271K   47M    1% /media/sessionR/Disque Dur 1
    

    What would you do?

    Still no luck. In fact I can't copy anything any more on the second disk (destination), it will always say it's full.

    Apparently the presence of filesystem files was what was wreaking havoc with copy/paste operations, which is a real problem as it's exactly what I'm trying to save!

    • Satō Katsura
      Satō Katsura about 7 years
      Since you ask: I'd use dump / restore instead of rsync.
    • SessionR
      SessionR about 7 years
      Never heard of dump / restore, I will look it it if I really can't figure rsync out. I guess it won't preserve permissions though ? That was my intended goal. I want to save my system every time before updating it so that I can restore in case of problems (I'm on the testing branch)
    • terdon
      terdon about 7 years
      How would you preserve permissions on an NTFS drive anyway?
    • user2948306
      user2948306 about 7 years
      You haven't actually identified the filesystem type, though it looks likely to be ntfs (ntfs-3g driver). Please show findmnt /dev/sdb2.
    • SessionR
      SessionR about 7 years
      @terdon I was under the impression that -a : Archive mode would preserve permissions. -a : The files are transferred in "archive" mode, which ensures that symbolic links, devices, attributes, permissions, ownerships etc are preserved in the transfer. I've read that one could use a .tar to preserve permissions on NTFS but I don't know if that's what -a does.
    • terdon
      terdon about 7 years
      I don't know much about this, but AFAIK, NTFS permissions are their own thing and getting them to play nice with Linux filesystems is possible but complex. Have a look here. The idea with tar is that the permissions are stored in the tarball and can be restored when you extract it on a filesystem that can do permissions. But I wouldn't expect this to work as you want with just an rsync.
    • SessionR
      SessionR about 7 years
      @terdon, interesting read. I'll look into the permissions of my /dev/sdb drive and the way its mounted via /etc/fstab. Still would be strange that some files get rsync'd until at some point a "No space left" error strikes because of permissions.
    • terdon
      terdon about 7 years
      Ah, no, the error you see shouldn't be related at all. That's why I'm posting comments and not answers. I was just pointing out that the premise of keeping permissions this way is flawed to begin with.
    • SessionR
      SessionR about 7 years
      @terdon, maybe so. If you have better options I'm all ears. I though that it'd work that way. Formatting the destination drive is annoying, it's still a bootable win7 that I used before and I'd like to keep it that way. Perhaps I could partition an ext4 on some free space but that's some work too and I don't know how win is going to react to that.
    • SessionR
      SessionR about 7 years
      @sourcejedi I'll get you the result of findmnt /dev/sdb2. As the destination drive is a bootable win7 I'm 99% positive the result will be NTFS. As @terdon explained, this may entail that all permissions are lost. But that doesn't explain the 'no space left' problem.
    • roaima
      roaima about 7 years
      So... NTFS does support extended attributes, which means you can save owernships, permissions, etc. using -M--fake-super (and restore them with --fake-super -M--super). I think this answers @terdon's comment about permissions.
    • SessionR
      SessionR about 7 years
      @roaima thanks for that nice side-question answer! I'll be using that.
    • SessionR
      SessionR about 7 years
      @sourcejedi I edited the original question. findmnt /dev/sdb2 TARGET SOURCE FSTYPE OPTIONS /media/sessionR/Disque Dur 1 /dev/sdb2 fuseblk rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permis‌​‌​sions,allow_other,‌​bl‌​ksize=4096
  • SessionR
    SessionR about 7 years
    When the dry run announces sent 2,554,663,982 bytes received 1,188,942 bytes 17,446,095.04 bytes/sec total size is 11,825,525,653 isn't it saying that only 11Gb are going to be transferred? I don't use encryption and I tweaked the --exclude={... so that .cache shouldn't be there. I'll look into it.
  • roaima
    roaima about 7 years
    $HOME/.cache would be excluded already due to the --exclude=/home/* rule. I thought that the encryption directory lived under $HOME too, BIC(E)BW on that one as I use disk-level encryption myself.
  • terdon
    terdon about 7 years
    @xhienne d'oh! Yes, of course it would. Never mind, I was being silly.
  • xhienne
    xhienne about 7 years
    @SessionR Well, you seem to be right. There is 11 GB in total and, even it obsolete files are deleted at the end of the rsync process, there is enough space on your external disk. I'm clueless. NTFS quotas maybe? You should really really reformat your disk to ext4.