# Identifying repack candidate tapes

**URL:** <https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295>\
**Category:** Site Administrators\
**Created:** [26 April 2024 20:11 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295 "2024-04-26T20:11:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ewv](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/ewv/32/26_2.png) [@ewv](https://cta-community.web.cern.ch/u/ewv)\
**Post date:** [26 April 2024 20:11 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/1 "2024-04-26T20:11:56Z")

</div>

How do you identify which tapes are ripe for a repack? I recently went through and deleted a large number of files. Going tape by tape and listing the files I can see that I have tapes where the majority of files are no longer in tapefile. I naively expected that tape ls would tell me how many active files were still on a tape.

Thanks!

Eric

---

<div class="post-metadata">

**Author:** ![rbachman](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/rbachman/32/33_2.png) [@rbachman](https://cta-community.web.cern.ch/u/rbachman)\
**Post date:** [26 April 2024 21:08 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/2 "2024-04-26T21:08:18Z")

</div>

Hi Eric,  
more often than not when we repack we pick tapes based on the media generation, repacking from an older generation on the way out to a new generation with higher capacity.

However, the [Automated Tape REpacking SYStem](https://gitlab.cern.ch/cta/cta-operations-utilities/-/tree/master/tools/pip/atresys?ref_type=heads) comes with a tool called [cta-ops-repack-0-scan](https://gitlab.cern.ch/cta/cta-operations-utilities/-/blob/master/tools/pip/atresys/src/atresys/cta_ops_repack_0_scan.py?ref_type=heads), which is intended for precisely this use case. It allows you to automatically select tape VIDs based on the percentage of their occupancy, filter by tape pool etc., and optionally feed those selected VIDs into the automated repacking system.

Additional info and install instructions can be found on the dedicated ops tool wiki: [Home · Wiki · cta / CTA Operations utilities · GitLab](https://gitlab.cern.ch/cta/cta-operations-utilities/-/wikis/home)

Cheers,  
Richard

---

<div class="post-metadata">

**Author:** ![ewv](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/ewv/32/26_2.png) [@ewv](https://cta-community.web.cern.ch/u/ewv)\
**Post date:** [26 April 2024 21:28 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/3 "2024-04-26T21:28:01Z")

</div>

Perfect! Thank you! This looks great.

---

<div class="post-metadata">

**Author:** ![ewv](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/ewv/32/26_2.png) [@ewv](https://cta-community.web.cern.ch/u/ewv)\
**Post date:** [29 April 2024 20:58 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/4 "2024-04-29T20:58:43Z")

</div>

On further examination, that script appears to be looking at master data in bytes divided by capacity. Which makes sense and was what I naively expected. However, we have a tape where every file has been put into the recycle log (visible in recycletf ls) and yet looks like this:

```auto
[
  {
    "vid": "FL0590",
    "mediaType": "LTO8",
    "vendor": "Unknown",
    "logicalLibrary": "TS4500G1_CTACMS",
    "tapepool": "cms.Run3Winter20DRPremixMiniAODMCGenSimRaw",
    "vo": "cms",
    "encryptionKeyName": "-",
    "capacity": "12000000000000",
    "occupancy": "11636563312201",
    "lastFseq": "1665",
    "full": true,
    "fromCastor": false,
    "readMountCount": "45",
    "writeMountCount": "28",
    "nbMasterFiles": "1665",
    "masterDataInBytes": "11636563312201",
    "state": "ACTIVE",
    "stateReason": "",
    "stateUpdateTime": "1707864003",
    "stateModifiedBy": "eosdev@cmscta01",
    "dirty": true,
    "verificationStatus": ""
  }
]

```

So any deletions are not reflected in the usage. Is there, perhaps, something we are missing which should be updating these columns as deletions happen?

```auto
[root@cmscta01 atresys]# XrdSecPROTOCOL=sss XrdSecSSSKT=/etc/cta/ctafrontend_forwardable_sss.keytab cta-admin --json rtf ls --vid FL0590|jq | grep fseq | wc
   1665 3330 32193

```

So all the files have been deleted in EOS

---

<div class="post-metadata">

**Author:** ![rbachman](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/rbachman/32/33_2.png) [@rbachman](https://cta-community.web.cern.ch/u/rbachman)\
**Post date:** [30 April 2024 08:11 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/5 "2024-04-30T08:11:48Z")

</div>

Hi Eric,  
so the `masterDataInBytes` of a tape is supposed to be computed by CTA as something along the lines of

```auto
masterDataInBytes = occupancy - size_of(deleted_files)

```

However, certain operations in CTA, such as a file being marked as deleted, don’t trigger immediate statistics updates.

You can force a statistics update when needed using the `cta-statistics-update` (from the CTA RPMs) script, which should result in an up-to-date `masterDataInBytes` value.

We run this script about once a day as part of our monitoring.

---

<div class="post-metadata">

**Author:** ![ewv](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/ewv/32/26_2.png) [@ewv](https://cta-community.web.cern.ch/u/ewv)\
**Post date:** [30 April 2024 20:09 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/6 "2024-04-30T20:09:36Z")

</div>

Thanks. This works great, of course. Are there any other such things which need to be done for a functional system? (As opposed to monitoring-only tasks?)

---

<div class="post-metadata">

**Author:** ![rbachman](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/rbachman/32/33_2.png) [@rbachman](https://cta-community.web.cern.ch/u/rbachman)\
**Post date:** [3 May 2024 08:17 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/7 "2024-05-03T08:17:54Z")

</div>

Hi Eric,  
yes we know having to call this somewhat obscure script is sub-optimal. It is scheduled for review at some point.

The other needed-for-production scripts/executions I can think of are more conditional, and not part of the core CTA software:

- If you are running a setup where pools feed tapes into other pools, then [tools/pip/poolsupply · master · cta / CTA Operations utilities · GitLab](https://gitlab.cern.ch/cta/cta-operations-utilities/-/tree/master/tools/pip/poolsupply?ref_type=heads), or some equivalent, is a must.
- A script or similar mechanism for allowing CTA to map encryption keys to tape pools, if enabled.
- Some way to actually move data between tapes, i.e. automation for large-scale repack: [tools/pip/atresys · master · cta / CTA Operations utilities · GitLab](https://gitlab.cern.ch/cta/cta-operations-utilities/-/tree/master/tools/pip/atresys?ref_type=heads)

---

<div class="post-metadata">

**Author:** ![fnal\_jeff](https://cta-community.web.cern.ch/user_avatar/cta-community.web.cern.ch/fnal_jeff/32/114_2.png) [@fnal\_jeff](https://cta-community.web.cern.ch/u/fnal_jeff)\
**Post date:** [12 June 2025 19:37 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/8 "2025-06-12T19:37:58Z")

</div>

How do we repack all M8 tapes in one logical library to LTO9 tapes in another logical library using ATRESYS? Can this be done regardless of VO?

---

<div class="post-metadata">

**Author:** ![vlado](https://cta-community.web.cern.ch/letter_avatar_proxy/v4/letter/v/779978/32.png) [@vlado](https://cta-community.web.cern.ch/u/vlado)\
**Post date:** [13 June 2025 13:11 UTC](https://cta-community.web.cern.ch/t/identifying-repack-candidate-tapes/295/9 "2025-06-13T13:11:22Z")

</div>

Dear Jeff,

Identifying all M8 tapes in a particular logical library is easy with these two commands (because we call M8 tapes LTO7M at CERN):

```auto
pcvlado ~ > cta-admin mt ls|grep LTO7M
     LTO7M LTO-7 9000000000000 93 0 168 2696 171097 mdavis ctadevmichael 2020-06-22 16:54 vlado ctaproductionfrontend01 2020-11-02 19:39 ctaproduction LTO-7 M8 cartridge formated at 9 TB                              

pcvlado ~ > cta-admin tape ls --mt LTO7M -l IBMLIB1-LTO8 | wc -l
6600

```

Once you have the list of VIDs, you can put them into a file (one VID per line) and submit all tapes for repack using `cta-ops-repack-1-prepare -F FILE` command.

What is more tricky is to make sure that the destination tapes are LTO9 tapes in another logical libraries. The only way to do it is to make sure that for each tape pools where the M8 tapes are located, the only supply tapes come from your desired destination LTO9 logical library.

Let me know if you need more explanations. Best regards,

Vladimir
